Many a times you will find that following error is showing while connecting to the postgres server from a different host/IP.
Error: psql: could not connect to server: Connection refused Is the server running on host "X.X.X.X" and accepting TCP/IP connections on port 5432?
CAUSE
The postmaster
or PostgreSQL’s server daemon process is not running or postgresql.conf settings are not configured properly.
SOLUTION
- Check whether postgres service is running or not. Use link to get all the commands for the same. Or access following page.
https://www.dbachamps.com/?p=607&preview=true&_thumbnail_id=476
2. If your service is up and running fine then the error is due to not having PostgreSQL configured to allow TCP/IP connections or at least not connections from your particular workstation. Check the following parameters.
postgresql.conf
not setup to allow TCP/IP connections. You’ll want to look at thelisten_address
configuration parameter.postgresql.conf
is not setup to allow connections on a non-standard port number. To determine this look at theport
configuration option.- authentication rules in PostgreSQL’s access configuration file (
pg_hba.conf
) are not setup to allow either your uses or IP address to connect to that database. - ensure that there are no firewalls, such as
iptables
that are keeping your local system from even establishing a connection to the remote host