Category / Section
How to Resolve the "Too Many Client Already" Error in Postgre SQL Data Source
Published:
You may encounter the error “too many clients already” when connecting to a PostgreSQL data source. This error occurs when there are too many open connections to the PostgreSQL server. This article will guide you through the steps to resolve this issue.
Cause
An excessive number of open connections to the PostgreSQL server causes the error.
Solution
To resolve this issue, follow these steps:
-
To get the list of active connections, run the following query:
SELECT * FROM pg_stat_activity;
-
Run the following query to close the active connections.
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE pid <> pg_backend_pid() AND datname IS NOT NULL AND leader_pid IS NULL;
You should be able to resolve this issue by closing the active connections.