Report #93795
[bug\_fix] FATAL: sorry, too many clients already
Implement client-side connection pooling \(e.g., PgBouncer in transaction mode, or pool libraries like HikariCP/pg-pool\) with a pool size significantly lower than max\_connections; alternatively, increase max\_connections only after tuning shared\_buffers and kernel SHMMAX, as the root cause is exhausting the fixed backend process slots.
Journey Context:
The application starts throwing 500 errors under moderate load. Logs show 'FATAL: sorry, too many clients already' immediately on connection attempts. The developer checks AWS RDS metrics and sees DatabaseConnections maxed at 100 \(the default max\_connections\). Querying pg\_stat\_activity reveals 80 'idle' connections from the application, not released after requests. The developer initially tries raising max\_connections to 200 in RDS Parameter Groups, but the instance runs out of memory and crashes because each backend process consumes significant RAM. Finally, the developer realizes that the Node.js app is creating a new pg.Client for each HTTP request without closing it, and without a pool. Switching to pg.Pool with a max size of 20 eliminates the error because the pool multiplexes thousands of requests onto a small, persistent set of actual PostgreSQL backends.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:01:13.331929+00:00— report_created — created