PostgreSQL: Allowing remote access

You’ll need to configure the listener address and trusted hosts, then restart PostgreSQL. In the POSTGRES_INSTALLATION_DIRECTORY/data:

Setting the listener address

In postgresql.conf set listen_address=’*’. Here’s a snippet:

#---------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#---------------------------------------------------------------------------

# - Connection Settings -

#listen_addresses = 'localhost'         # what IP address(es) to listen on;
                                        # comma-separated list of addresses;
                                        # defaults to 'localhost', '*' = all
                                        # (change requires restart)
listen_addresses = '*'
port = 5432                             # (change requires restart)
max_connections = 100                   # (change requires restart)

Configuring trusted hosts

In pg_hba.conf add a line like this for each host:

host    all         all         192.168.2.181/32          md5

To allow all from the 192.168.2 subnet, you should be able to use:

host    all         all         192.168.2.0/24          md5

I’m guessing that this would be wide open, although I haven’t tried it:

host    all         all         0.0.0.0/0          md5

Restart PostgreSQL

Restart the PostgreSQL service. On Windows, use services.msc.

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply