Can't remotely connect to postgresql

920 views Asked by At

I have followed all the advice I've found online, but I can't seem to get this to work.

Background:

I have setup Postgresql 9.6 on a server running RHEL 6.8. I am trying to remotely connect to this server's Postgresql service from a client running Linux Mint 17.3.

What I've tried:

1) In postgresql.conf, I added these two lines:

listen_addresses = '*'
port = 5432

2) In pg_hba.conf, I added this line:

host all all 0.0.0.0/0 md5

3) Restarted postgresql server afterwards:

service postgresql-9.6 restart

4) Added rule to firewall to allow connections to port 5432 just in case:

iptables -A INPUT -s 0/0 -p tcp --dport 5432 -j ACCEPT

5) Ran netstat -tulpn | grep 5432 and got this output:

tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 2625/postmaster
tcp 0 0 ::::5432     :::*      LISTEN 2625/postmaster

Here is the command I ran to connect to my server from the client:

psql -h my_host_name -d my_database_name -U postgres

And I got the following output:

psql: could not connect to server: Connection timed out
    Is the server running on host "my_host_name" (my_ip_address) and accepting
    TCP/IP connections on port 5432?

Question:

What else can I do to further troubleshoot this issue?

1

There are 1 answers

0
Sam Parsons On

Turns out there was another firewall on our network that I wasn't taking into account. To anybody else dealing with this issue, make sure that you are absolutely sure that you are not dealing with a firewall.