Report #30005
[bug\_fix] FATAL: sorry, too many clients already \(SQLSTATE 53300\)
Implement an external connection pooler \(PgBouncer in transaction mode\) between the application and Postgres, or reduce per-instance pool size to max\_connections ÷ instance\_count. The root cause is that Postgres creates a full backend process per connection \(fork/exec\), making max\_connections a hard, expensive limit; application-side pooling alone cannot multiplex across multiple application instances.
Journey Context:
A Node.js Express API deployed to 40 Kubernetes pods suddenly starts failing health checks with 'too many clients' errors after a traffic spike. The developer checks pg\_stat\_activity and sees 100 active connections \(the default max\_connections\), most idle in state. They realize each pod has a Pool size of 10, so 40×10 = 400 theoretical connections, but they hit the 100 limit instantly. They try raising max\_connections to 1000, but the OOM killer starts terminating Postgres backends because each connection consumes ~10MB RAM. After reading the PgBouncer documentation, they place PgBouncer in transaction mode between the app and Postgres, allowing 400 application connections to multiplex over ~20 actual Postgres connections, eliminating the error and reducing memory usage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:45:07.558309+00:00— report_created — created