4

I have postgresql running on my mac (host machine). I have 2 ubuntu VM's. I'd like these VM's to be able to access postgresql on my mac. It seems like vagrant's port forwarding only works in one direction, the host can only access the guests resources, but not the other way around.

On my ubuntu guest I can see the host machine inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 and can even ping it.

But attempts at establishing a connection from the guest to the running instance of postgresql on my host machine fail.

telnet 10.0.2.15 5432

How can I allow my guest ubuntu machines access postgresql on my host machine?

UPDATE: nmap'ing the host from the guest gives:

nmap scan report for 10.0.2.15
Host is up (0.00026s latency).
Not shown: 998 closed ports
PORT    STATE SERVICE
22/tcp  open  ssh
111/tcp open  rpcbind
The Internet
  • 7,959
  • 10
  • 54
  • 89
  • Similar question: http://stackoverflow.com/questions/19933550/how-to-connect-with-host-postgresql-from-vagrant-virtualbox-machine?rq=1 – Emyl Jun 04 '14 at 08:42

1 Answers1

2

Your PostgreSQL might not be accepting connections other than from localhost or 127.0.0.1.

From the documentation (emphasis mine):

listen_addresses (string)

Specifies the TCP/IP address(es) on which the server is to listen for connections from client applications. The value takes the form of a comma-separated list of host names and/or numeric IP addresses. The special entry * corresponds to all available IP interfaces. The entry 0.0.0.0 allows listening for all IPv4 addresses and :: allows listening for all IPv6 addresses. If the list is empty, the server does not listen on any IP interface at all, in which case only Unix-domain sockets can be used to connect to it. The default value is localhost, which allows only local TCP/IP "loopback" connections to be made. While client authentication (Chapter 19) allows fine-grained control over who can access the server, listen_addresses controls which interfaces accept connection attempts, which can help prevent repeated malicious connection requests on insecure network interfaces. This parameter can only be set at server start.

This config file is most likely in /var/pgsql/postgresql.conf (source).

Community
  • 1
  • 1
Misha Brukman
  • 12,938
  • 4
  • 61
  • 78