By ajain99
I bought a VPS from DigitalOcean. I installed Postgresql 9.3 and trying to accept remote connections from that. I read all of the solutions/problems about it (Googled much) and did exactly. The problem is the following:code
psql: could not connect to server: Connection refused Is the server running on host “xxx.xxx.xxx.xxx” and accepting TCP/IP connections on port 5432?
I edited the postgresql.conf file with listenaddresses=‘*’ I edited the pghba.conf file and added host all all 0.0.0.0/0 md5 I restarted postgresql service and even the VPS however still I cannot connected to the database. So I tried to check the server’s listening ports:
netstat -an | grep 5432 tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:42208 127.0.0.1:5432 ESTABLISHED tcp 171 0 127.0.0.1:42199 127.0.0.1:5432 CLOSE_WAIT tcp 0 0 127.0.0.1:5432 127.0.0.1:42208 ESTABLISHE unix 2 [ ACC ] STREAM LISTENING 8356 /tmp/.s.PGSQL.5432
and then I nmap’ed the server from different machine:
Not shown: 996 closed ports PORT STATE SERVICE 21/tcp open ftp 22/tcp open ssh 80/tcp open http 443/tcp open https
But still I cannot understand why postgresql not serving at the port 5432 after the configurations. I thought it might be caused by iptables. So that I add the following rules:
iptables -A INPUT -p tcp -m tcp --dport 5432 -j ACCEPT iptables -A OUTPUT -p tcp -m tcp --dport 5432 -j ACCEPT
I have contacted to support also but solution.
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!
Accepted Answer
This comment has been deleted
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.