5.2 Configuring PostgreSQL to Accept Remote Database Connections

To configure the PostgreSQL database to accept remote database connections, you need to add the following line to the /var/lib/pgsql/data/pg_hba.conf file:

host    all      all         0.0.0.0/0      trust

NOTE:After initial configuration, you can replace the 0.0.0.0/0 with a more restrictive mask. In a high availability server configuration, make sure that each host in the high availability cluster is enabled as a remote host.

For added security, the /var/lib/pgsql/data/pg_hba.conf file should list only the desired hosts. For example, only the Orchestration Server would be included in the trust line.

After you make the change to the pg_hba.conf file, you need to specify the following command so that you do not receive an error when remote hosts try to connect:

pg_ctl reload

If pg_hba.conf is not configured andyou attempt to connect, an error similar to the following is displayed:

psql: FATAL:  no pg_hba.conf entry for host "164.99.15.64", user "postgres", database "postgres", SSL off

Depending on the environment, you might need to perform some additional configuration for remote database setup. Editing the listen_addresses section of the postgresql.conf file enables the database server to listen for incoming connections on the specified IP addresses. The following is an excerpt from that section of the file:

listen_addresses = 'localhost'
                    # what IP address(es) to listen on;
                    # comma-separated list of addresses;
                    # defaults to 'localhost', '*' = all

After you modify the listen_addresses entry in postgresql.conf, use the following command to restart the PostgreSQL server (recommended in the PostgreSQL documentation):

pg_ctl restart