So, we installed PostgreSQL and are trying to connect via psql from a remote host. However, we get the following error:
The first thing we need to do is log in to the machine where PostgreSQL is supposed to be running and check whether the server process is there. We can use the ps
command to find this out:
ps aux | grep postgres
If we don't see the processes: the writer process, wal writer process, and so on, we know that the server has not started. We can start the service and try again. If we get the same error again, the next step is to confirm that it's indeed listening at the port we are trying to connect to. To do this, use the following command:
ss -anp | grep postgres
We should see entries for port 5432
. We can also log in to the database server, connect to psql, and try the following commands:
postgres=# SHOW port; port ------ 5432 postgres=# SHOW listen_addresses; listen_addresses ------------------ localhost