Question

cannot access remotly to postgres using psql

I am trying to access to postgresql remotly using psql. Can it be that a firewall is blocking postgresql default port 5432 ?

I did the following modification in pg_hba.conf

host    all             all             80.240.129.47/24        trust

and allowed everyone to listen in postgresql.conf

listen_addresses='*'

I do not know, what still is missing to make in run?

When starting nmap from a different host the port of postgres is not shown.

any idea??

Markus


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

wait Andrew I got it. it was wrongly set in my pg_hba.conf. 80.240.129.47 is the host of the server and not of the client. My mistake and sorry for bothering.

Markus

Hi, thanks for your quick response

I assume this. I set up the following rule:

sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             80.240.129.47        tcp spts:1024:65535 dpt:postgresql state NEW,ESTABLISHED

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  80.240.129.47        anywhere             tcp spt:postgresql dpts:1024:65535 state ESTABLISHED

I hope this is correct.

kind regards

Markus

If you have listen_addresses='*' and nmap doesn’t show port 5432, it is very likely that your firewall is blocking the port. Have you set up any IP table rules?

Is the IP address 80.240.129.47 the IP of your server or the IP of the machine connecting to it? It should be the address of the client that will connect to the server. Check out the pg_hba.conf docs.