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.
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.
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:
https://www.pgadmin.org/download/
2. Reconnect the connection
Another method to fix this error is to try reconnecting the connection.
We can do this with the following steps:
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.
This article covers methods to resolve pgAdmin "connection to the server has been lost" error for our customers. When connecting to a PostgreSQL server, you may get this error message. From the error message you will be able to resolve the problem.
If pgAdmin displays this message, there are two possible reasons for this:
For security reasons, a PostgreSQL server "out of the box" doesn't listen on TCP/IP ports. Instead, it must be enabled to listen for TCP/IP requests. This can be done by adding listen_addresses=’*’; this will make the server accept connections on any IP interface.