Remote access to a PostgesQL server
A quick note to myself in case I have to do this again, or in case it helps someone else get through the same task more quickly. Gotchas to watch out for when enabling access to a PostgresQL server from another machine:
- The line in
postgres.conf
that sayslisten_addresses = 'localhost'
needs to be changed to the actual hostname of the server, becauselocalhost
only enables listening on the loopback interface (i.e. the server can listen to connections from clients running locally, but not on any other machines) - To allow connection from any host on the same network, add a line to the
pg_hba.conf
saying:host all all 16.0.0.0/8 password
This says: allow access from any (remote) host, where any user (first all) can access any database (second all) if identified by password, and the IP address of the remote host begins16.
- counting the first eight (from the/8
) binary digits as significant. The non-matched digits have to be zero, hence the0.0.0
at the end.