LMSouq
server-admin Open

"psql: could not connect to server: Connection refused" Error when connecting to remote database

PO
Poonam Anthony
1 month ago
3 views
Problem Description
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` -d `db_name` This is the error that occurs: > psql: could not connect to server: Connection refused Is the server running on host "<host_ip>" and accepting TCP/IP connections on port 5432? 1. Postgres installed version is 9.4. 2. Host operating system: Ubuntu 15.04 3. Client operating system: Centos 7 I already tried the following but the issue remains unresolved: 1. Edited `pg_hba.conf` file to include > host all all 0.0.0.0/0 md5 2. Edited 'postgresql.conf' and changed the listen parameter to > listen_addresses='*' 3. Restarted Postgres service. 4. Disabled firewall and iptables on host and client. 5. I checked by running the psql command locally and it worked. 6. I tried the second solution given in this [question][1]. 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. [1]: https://stackoverflow.com/questions/6150738/cannot-connect-to-postgres-from-remote-host

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base