I am trying to enable Postgresql 9.3 to accept remote connections on CentOS6. I opened the port in iptables, set the port to 5432 in the pgconf file, set listen_addresses to '*' (accept all connections), and allow addresses in the pg_hba with host all all 0.0.0.0/0 trust. The postmaster is running on 5432. However, I still receive the following error. How do I get a valid connection?
The error:
could not connect to server: Connection refused
Is the server running on host "50.63.141.236" and accepting
TCP/IP connections on port 5432?
Relevant part of pg_hba.conf file:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
#opens postgres to the internet
host all all 0.0.0.0/0 trust
Relevant output from iptables -L:
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:postgres
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:postgres
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:postgres
Finally, proof that postmaster is running.
EN 1433/sshd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LIST
0.0.0.0/0matches all IP addresses, because the subnet mask prefix/0doesn't mask anything. So that's OK, so long as you're not Internet-facing. - Craig Ringer