Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a VM with IP address running postgreSQL.

If I specify

listen_addresses = '*'

then I can connect from another VM at and from localhost.

But I can't seem to use a list to tell postgreSQL to use those two addresses. If I change listen_addresses to a list:

listen_addresses = ', localhost'

then I can no longer connect from

I notice that almost all examples on stackexchange set listen_addresses to '*'. Is this because the list form does not work?

share|improve this question
You should accept the answer. – Kenny Evitt Jun 20 '15 at 18:18
up vote 23 down vote accepted

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 = ', localhost'

If the local machine has IP, you should specify that IP, not the remote host 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 ', localhost'. Or just *, since you probably actually want to listen on all network interfaces.

share|improve this answer
It works. So is there any practical difference between the list and '*'? – zabouti Aug 20 '13 at 3:37
@zabouti Sure. If your server has (say) two external network interfaces, you can tell PostgreSQL to only bind on one of them, so it's not even possible to make a TCP connection to Pg on the other. It's mostly an extra level of security for a system that has multiple interfaces to different security domains. Quite handy in combination with VLANs, virtual switches, etc. The most common use is setting it to localhost so that TCP/IP connections are not possible from any external network interface, only the loopback address. – Craig Ringer Aug 20 '13 at 4:03
@CraigRinger: a very good answer! – francs Feb 25 '14 at 5:27
@CraigRinger you should add those comments to your answer. That's very useful information. – João Portela Dec 18 '14 at 10:57
Yeah I think the comment might be even better than the answer. Rock on Craig! – user973810 Oct 7 '15 at 18:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.