I have configured Postgres to accept network connections from anywhere:
In pg_hga.conf:
host all all 0.0.0.0/0 md5
In postgresql.conf:
listen_addresses = '*'
I can see the server is listening
vagrant@vagrant-ubuntu-trusty-64:~$ sudo netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
<snip>
tcp 0 0 0.0.0.0:5433 0.0.0.0:* LISTEN 1570/postgres
I've configured iptables to allow incoming TCP connections to 5433
vagrant@vagrant-ubuntu-trusty-64:~$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:5433
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
From an ssh session in the VM, I can run telnet 10.0.2.15 5433
and it works. I can also connect with the full psql client. From my host, if I run the same telnet command or the same psql command, I can't connect.
What can be wrong and what can I check?