Can listen_addresses really be set to a list?

Yes, listen_addresses can be set to a list of addresses on the local host to bind to for listening.

In your example:

listen_addresses = '192.168.0.191, localhost'

If the local machine has IP 192.168.0.192, you should specify that IP, not the remote host 192.168.0.191 IP. PostgreSQL cannot bind to the IP address of a remote host.

You're not saying "who is allowed to connect", you're saying "which interfaces should PostgreSQL accept connections on". The "who's allowed to connect" bit is next, and is configured in pg_hba.conf.

So: Try '192.168.0.192, localhost'. Or just *, since you probably actually want to listen on all network interfaces.


I've found that instead of using localhost it needs to be 127.0.0.1 if you're specifying any other addresses as well.

So in my case of listening on the Docker host IP address as well as localhost, but not the external IP, this doesn't work (I get a connection refused from inside my Docker containers):

listen_addresses = '172.17.0.1, localhost'

But this does:

listen_addresses = '172.17.0.1, 127.0.0.1'

Tags:

Postgresql