Configure a PostgreSQL database cluster to accept connections

By default, only clients running on the same machine as the PostgreSQL database cluster can connect to it. To allow remote clients to connect to the database cluster, alter the PostgreSQL pg_hba.conf configuration file. The entries you place in the pg_hba.conf file will vary depending on security policies and configurations at your site.

Complete the following steps to allow connections from clients on machines that are remote from the PostgreSQL server:

  1. Make a backup copy of the pg_hba.conf file before you alter it.
  2. Open the pg_hba.conf file in a text editor.
  3. Add the IP addresses of connecting client machines, designate the database or databases each IP address can connect to, and specify the client authentication methods used for connections.

    See the PostgreSQL documentation for more information.

  4. Save and close the pg_hba.conf file.
  5. If PostgreSQL is installed on a Linux server, reload server configuration settings using a PostgreSQL function such as pg_ctl reload or pg_reload_conf().
  6. Ensure users have privileges to connect to the database.

    By default, the Public group role has CONNECT privileges to all databases in the PostgreSQL database cluster, so you only need to grant the CONNECT privilege to individual login or group roles on specific databases if you revoked the CONNECT privilege from the Public role.