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:


# - 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          md5

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

host    all         all          md5

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

host    all         all          md5

Restart PostgreSQL

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

It's only fair to share...
Share on Facebook
Tweet about this on Twitter
Share on LinkedIn

Leave a Reply