Report #9919
[bug\_fix] FATAL: sorry, too many clients already
Implement client-side connection pooling \(e.g., node-postgres Pool, SQLAlchemy QueuePool\) or deploy PgBouncer in transaction pooling mode. Root cause: PostgreSQL spawns a backend process per connection and enforces a hard max\_connections limit \(default 100\); exhausting this prevents new connections and already-idle connections from other apps compound the issue.
Journey Context:
You deploy a Node.js Express API to production. Under a load test with 150 concurrent users, the API starts throwing FATAL: sorry, too many clients already. You query pg\_stat\_activity and see 100 idle connections held by your app server, each from an earlier request that called pg.Client.connect\(\) but never called end\(\). You realize you created a new client per HTTP request. You refactor to use a singleton new Pool\(\{ max: 20 \}\) and ensure pool.query\(\) releases the client automatically. The connection count stabilizes at 20 and the error disappears.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:21:38.326116+00:00— report_created — created