Reloading the PostgreSQL configuration without restarting the entire database can be efficiently achieved using the pg_ctl reload
command. Performing Postgres reload config is a simple one-liner and should be part of your toolbox.
Table of Contents
Why is Postgres Reload Config Important?
If you are making modifications to the Postgres configuration file postgresql.conf (or similar), and you want to new settings to take effect, reload Postgres config without restart in one of the ways shown below. Another similar command essential to PostgreSQL, is to reload pg_hba.conf.
Method 1: From the command-line shell
From the command-line prompt on your Linux server, run the following command:
su - postgres /usr/bin/pg_ctl reload
Method 2: Using psql
From the command-line run the psql command and run the following SQL statement:
SELECT pg_reload_conf();
Method 3: Using systemctl reload postgresql
Using systemctl to reload the PostgreSQL configuration is a method common in Linux-based systems. In order to reload the PostgreSQL configuration without interrupting the database service, you simply need to type sudo systemctl reload postgresql
in the command line. This command tells the system to load the latest configuration changes. It’s an effective way of ensuring your PostgreSQL system runs with the most updated settings without causing any downtime.
Using any method will not interrupt any active queries or connections to the database, thus applying these changes seamlessly.
Tip: If you are making changes to your pg_hba.conf file, see PostgreSQL reload pg_hba.conf without restart.
Or using SQL (by a superuser):
SELECT pg_reload_conf();
Thanks Frank for that suggestion. I will update the article accordingly!
This does not work for all settings. See the postgres docs. Some parameters state: “This parameter can only be set at server start.”
Thanks.
I’m new to PostgreSQL and things like this makes life easier for me 🙂
Well it should be ….
pg_ctl reload -D /datafile-location
Thanks, very helpful.
SELECT pg_reload_conf();
Worked perfectly.
As others have stated, be sure your configuration changes don’t require a restart!
Cheers
Saved my homework. Thnks!
Thank you very much
thanks, you saved my day