3

I'm trying to access a postgres database remotely and I can't for the life of me get it to work.

I've installed a Gen 2 linux VM in Azure with Ubuntu 14.04 and installed postgres. SSH works remotely, and psql works fine while remoted in.

Steps I've taken:

  1. updated postgresql.conf listen_addresses to be '*' and confirmed via psql and show listen_addresses that it's listening to *.

  2. Updated pg_hba.conf by adding host all all 0.0.0.0/0 md5.

  3. Added an inbound allow rule in the Azure Network security group for port 5432. enter image description here

  4. Restarted postgres/ubuntu.

After these steps, I'm able to work with and access psql just fine, but whenever I attempt to remotely connect to the instance via pgAdmin3, I get an error stating that the connection timed out.

Further, when I use a port checker remotely, port 5432 is reported as closed.

What am I missing/doing incorrectly?

Thanks in advance.

Update:

Here is the current output of iptables -S enter image description here

  • Have you also checked if you have any firewall configured in the server itself? What is the output of iptables -S? – Diamant Feb 5 '16 at 22:01
  • @bangal, I'm a little out of my depths on the firewall configure. At one point I had added an IP table entry, but my updated question has the current output of iptables -S. I don't see my entry for 5432... – Grant H. Feb 5 '16 at 22:34
2

Sounds like you need to use iptables-persistent

See

http://postgresql.freeideas.cz/install-postgresql-9-5-on-ubuntu-14-04/

  • I've added that to the mix, but turns out that wasn't the problem. – Grant H. Feb 6 '16 at 0:16
1

So, for some reason, this is an Azure issue. I opened port 5432, but that didn't work. In a move of desperation, I've opened 1024-65535, and now I can connect. Clearly I'm missing something related to the usage of inbound rules. While this does fix my issue, it's clearly not a best practice. Any thoughts on what I'm missing?

0

Had the same problem, the port is somewhere between 25000-27500. You could keep trying to narrow it down but that seemed good enough for me for now - better than exposing every port. I also have another rule that leaves port 5432 open.

0

I was facing the same issue on Azure VM - Linux. I tried below

Change PG_hba.conf Change postgres.conf Add Rule in Firewall using Azure Portal

but was unable to connect using pgadmin. But once I run below command I was able to connect.

iptables -I INPUT 1 -m tcp -p tcp --dport 5432 -j ACCEPT

Above work for me absolutely. After spending so many hours :)

All the best !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.