Report #84577
[bug\_fix] FATAL: sorry, too many clients already \(Postgres connection exhaustion\)
Deploy PgBouncer \(or similar pooler\) in transaction pooling mode between the application and Postgres, or reduce per-instance connection pool sizes to ensure total connections remain below max\_connections \(default 100\).
Journey Context:
A Node.js service deployed on Kubernetes with 10 pods, each configured with a connection pool of 20, suddenly starts throwing FATAL: sorry, too many clients already errors under load. Investigation via pg\_stat\_activity reveals 100 idle connections \(the default max\_connections\), confirming the aggregate demand \(10×20=200\) exceeds Postgres capacity. Attempting to increase max\_connections to 200 fails due to kernel SHMMAX limits and requires increasing shared\_buffers, risking OOM. The root cause is that each pod maintains persistent TCP connections even when idle. The fix introduces PgBouncer in transaction pooling mode, which multiplexes hundreds of lightweight client connections onto a small fixed pool of actual Postgres connections \(e.g., 20\), eliminating the error without changing Postgres configuration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:33:07.977324+00:00— report_created — created