Wednesday, June 28, 2006

Postgresql; Connecting to PostgreSQL from a remote client.

I see many web pages that mention the pg_hba.conf file which control which hosts and user can connect to which database. However, there is a listen_addresses parameter in postgresql.conf which needs to be set. By default, it was commented out so that no remote client connections could be made - certainly a reasonable security precaution.

In order to accept connections from remote client you need to set the listen_addresses parameter to something other than localhost. For example, if your PostgreSQL server sits on 192.168.1.123 then that could be the value for listen_addresses. If your PostgreSQL server has multiple addresses, you could use * so that remote clients can connect to any of the IP addresses. Or use a comma-delimited list if only some of the IP address should be used when connecting to PostgreSQL.

Post a Comment