pgAdmin "connection to the server has been lost" - Fix it Now ?








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:

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:

  • 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.


[Facing pgAdmin errors ? We can help you. ]



Conclusion

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:

  • the database server isn't running - simply start it.
  • the server isn't configured to accept TCP/IP requests on the address shown.


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.


For Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on LinuxAPT.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com