Problem:
I am trying to connect to a Postgres database installed in a remote server using the following command: Psql-h- host_ip U- db_username Ddb_name This error is occurs:
Psql:could not connect to Server:connection refused are the server running on host "" and accepting TCP/IP connections on Port 5432?
- Postgres installed version is 9.4.
- Host operating System:ubuntu 15.04
- Client Operating System:centos 7
I already tried the following but the issue remains unresolved:
- Edited
pg_hba.conf file to include
Host All 0.0.0.0/0 MD5
- Edited ' postgresql.conf ' and changed the listen parameter to
Listen_addresses= ' * '
- Restarted Postgres service.
- Disabled Firewall and Iptables on host and client.
- I checked by running the Psql command locally and it worked.
- I tried the second solution given in this question. Running
nmap gave me the following output:
Starting Nmap 6.47 ( http://nmap.org ) at 2015-09-07 18:08 IST Nmap scan report for 10.17.250.250 Host is up (0.0000040s latency). Not shown: 997 closed ports PORT STATE SERVICE 22/tcp open ssh 25/tcp open smtp 80/tcp open http
Am I missing something. Hope someone can help. PostgreSQL Ubuntu Psql Centos7
ShareEdit |
Asked Sep 7 ' at 12:48poonam Anthony4395 |
|
|
|
Firewall is still blocking port 5432. Check your configs for iptables. –dmitry Savinkov Sep 7 ' at 17:03 |
|
@Dmitry I disabled iptables by running sudo ufw disable , but I ' m still getting the same Error.–poonam Anthony Sep 8 ' 10:2 5 |
|
Can you try a ' netstat-na|grep 5432 ' and see if PostgreSQL binds to all interfaces? –kometen Dec ' at |
|
----------------------------------------------------------------------------
cd /etc/postgresql/9.x/main/
Open file namedpostgresql.conf
sudo vi postgresql.conf
Add this line to the file
listen_addresses = ‘*‘
Then open file namedpg_hba.conf
sudo vi pg_hba.conf
and add this line to the file
host all all 0.0.0.0/0 md5
It allows access to all databases for all users with an encrypted password
Restart your server
sudo /etc/init.d/postgresql restart
"Psql:could not connect to Server:connection refused" Error while connecting to remote database