Report #76080
[bug\_fix] FATAL: sorry, too many clients already \(SQLSTATE 53300\)
Implement a connection pooler \(PgBouncer or pgpool\) in transaction pooling mode, or increase max\_connections with memory calculation. Root cause: PostgreSQL forks a backend process per connection; exhausting max\_connections \(default 100\) via connection leaks or oversized pools exhausts memory and process table.
Journey Context:
A Node.js service deployed to Kubernetes works locally but fails in production under load with 'sorry, too many clients already'. The developer checks pg\_stat\_activity and sees 100 idle connections from previous pod versions that didn't close properly. Initially, they increase max\_connections to 500, but OOM killer strikes because each connection consumes work\_mem \+ overhead. After tracing, they realize each microservice replica opens 20 connections and they have 20 replicas. They implement PgBouncer in transaction mode, reducing actual PostgreSQL connections to 50 while allowing thousands of application-side connections, eliminating the backend exhaustion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:17:44.605100+00:00— report_created — created