Disconnect from a Database Server in pgAdmin 4

pgAdmin 4 allows you to connect to and manage PostgreSQL database servers with ease. However, there may be times when you need to disconnect from a server, such as when performing maintenance tasks, switching between servers, or simply closing an active session.

In this tutorial, we will go through a detailed guide on how to safely disconnect from a PostgreSQL database server using pgAdmin 4.


Step 1: Open pgAdmin 4

Launch pgAdmin 4 on your system if it is not already open. You can access it via your applications menu or web browser, depending on how pgAdmin 4 is installed on your system.

Disconnect from a Database Server in pgAdmin 4 - Step 1: Open pgAdmin 4

Once launched, you will see the pgAdmin 4 dashboard, which displays a hierarchical tree structure of servers and databases in the left-hand navigation panel.

Disconnect from a Database Server in pgAdmin 4 - hierarchical tree structure of servers

If you are already connected to a server, it will appear expanded in the tree view, showing its databases, schemas, and other components.


Step 2: Locate the Server Connection

In the left-hand navigation panel, under the “Servers” node, locate the server you wish to disconnect from. If the server is currently connected, its node will appear expanded, displaying its child nodes such as “Databases,” “Schemas,” and other objects. This indicates an active connection to the server.

In the following screenshot, the server TutorialKart Postgres 17 Server is connected, which is why we could see the tree structure.

Disconnect from a Database Server in pgAdmin 4 - Step 2: Locate the Server Connection

If the server is not connected, it will appear as a collapsed node, and no further action is required to disconnect it.


Step 3: Disconnect from the Server

To disconnect from the server, right-click on its name TutorialKart Postgres 17 Server in the tree view. From the context menu that appears, select the Disconnect from Server option.

Disconnect from a Database Server in pgAdmin 4 - Step 3: Disconnect from Server

This action will terminate the connection between pgAdmin 4 and the PostgreSQL server.

Disconnect from a Database Server in pgAdmin 4 - Step 3: Disconnect from the Server - Click Yes in Dialog

Upon successful disconnection, the server node will collapse, and the tree structure beneath it will no longer be visible.

Disconnect from a Database Server in pgAdmin 4 - Step 3: Disconnected from the Server

The server is now disconnected, and you will no longer be able to access its databases or objects until you reconnect.

If you attempt to interact with a disconnected server (e.g., expanding its node), pgAdmin 4 will prompt you to reconnect by entering the necessary credentials.


Step 4: Verify the Disconnection

To confirm that the server has been disconnected, check the state of the server node in the navigation panel. A disconnected server will appear as a collapsed node with no child nodes visible.

Additionally, attempting to expand the node will prompt you to reconnect, indicating that the disconnection was successful.

Disconnect from a Database Server in pgAdmin 4 - Step 4: Verify the Disconnection

Disconnecting ensures that no active sessions or queries are running against the server from pgAdmin 4.


Conclusion

Disconnecting from a database server in pgAdmin 4 is is particularly useful when managing multiple servers or performing maintenance tasks. Remember that you can always reconnect to the server whenever needed by selecting the Connect option.