PostgreSQL: How to reload config settings without restarting database

postgresql show tables

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.

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.

See also  How to Start PostgreSQL Automatically on Ubuntu Boot

10 thoughts on “PostgreSQL: How to reload config settings without restarting database”

  1. This does not work for all settings. See the postgres docs. Some parameters state: “This parameter can only be set at server start.”

  2. SELECT pg_reload_conf();
    Worked perfectly.

    As others have stated, be sure your configuration changes don’t require a restart!

    Cheers

Leave a Comment