I am trying to set up a Postgres server and I need it to be able to accept remote connections.
When I make a remote connection from a client, I keep on having this error:
Connection to 192.168.1.6:5432 refused.
Check that the hostname and port are correct and that the postmaster is accepting TCP/IP
I have already edited the file pg_hba.conf
with these line:
host all all 0.0.0.0/0 md5
and
host all all ::/0 md5
in order to accept every remote connection.
I have also edited the file postgresql.conf
setting the listen address to *
.
How can I solve this problem?
ssh to your server and issue command
netstat -tlpn | grep 5432
You should get the similar outputtcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 31309/postmaster tcp 0 0 :::5432 :::* LISTEN 31309/postmaster
That means postgres is ready to accept remote connections on port 5432. Otherwise you need to recheck listen parameter in postgresql.conf and restart postgresql cluster (not reload). If you still can't get remote access, try to temporarily disable firewall on server and client
iptables -F