Report #35503
[bug\_fix] FATAL: sorry, too many clients already \(SQLSTATE 53300\)
Root cause: Direct connections to PostgreSQL exhausting the backend max\_connections limit \(default 100\), often because each application instance creates connections without an intermediary pooler. Fix: Deploy PgBouncer \(or similar\) in transaction pooling mode between applications and Postgres. This multiplexes many client connections onto few backend connections. Do not simply raise max\_connections \(causes memory pressure and performance degradation\).
Journey Context:
Application works in staging with 2 replicas, but fails immediately in production under load with FATAL errors. Checking pg\_stat\_activity shows 100 active connections, mostly IDLE from various app instances. Realizing each of the 20 Kubernetes pods creates 5 direct connections on startup, exceeding the limit. Implementing PgBouncer with pool\_mode=transaction reduces backend connections to 10 regardless of pod count, resolving the issue.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:03:56.707078+00:00— report_created — created