Sometimes, our Customers using PostgreSQL report to us that they get this error while trying to connect to PostgreSQL via pgAdmin.
Generally, this pgAdmin error indicates that the connection attempt has taken longer than the specified threshold; there may be a problem with the connection properties provided on the Server dialog, network connectivity issues, or the server may not be running.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to resolve related PostgreSQL errors.
What triggers pgAdmin "connection to the server has been lost" error?
A typical error looks like this:
Connection to the server has been lost
Basically, connection to the server has been lost error means that the connection attempt has taken longer than the specified threshold; there may be a problem with the connection properties provided on the Server dialog, network connectivity issues, or the server may not be running.
How to fix pgAdmin "connection to the server has been lost" error?
1. Upgrade Pgadmin
We may get this error with pgadmin4 and it does not support PostgreSQL 9.
To fix this error we can upgrade to pgAdmin4 version 2.0.
We can do this from the URL given below:
2. Reconnect the connection
Another method to fix this error is to try reconnecting the connection.
We can do this with the following steps:
- First select the database where the connection was lost.
- Then select SQL. For example in the picture (shopdb) is the database the connection is lost.
- Now enter the image description here.
- After that PgAdmin will ask us if we would like to reconnect to this database. Now enter image description and click ok.
- We will notice a message retrieving data from the server.
3. Restarting PostgreSQL
This error could also trigger when the PostgreSQL database is not working. However, we can fix this by restarting the service.
This can be done with the following command:
# sudo service postgresql restart
After restarting we can try reconnecting to PostgreSQL again.