Report #36152
[bug\_fix] FATAL: sorry, too many clients already
Deploy a connection pooler such as PgBouncer \(in transaction pooling mode\) between the application and Postgres, or increase max\_connections in postgresql.conf \(requires a server restart\) while proportionally increasing shared\_buffers to avoid memory exhaustion. The root cause is Postgres’ process-per-backend architecture, where each connection consumes significant RAM; without pooling, traffic spikes exhaust the hard max\_connections limit.
Journey Context:
The application suddenly starts throwing connection errors during a traffic spike. Database logs show 'FATAL: sorry, too many clients already'. Querying pg\_stat\_activity reveals 100 active connections \(the default max\_connections\). Analysis shows many connections in 'idle' state from app servers holding session state. The application is creating a new connection per HTTP request without closing them promptly, or the client-side pool size is configured larger than max\_connections. Consulting the Postgres documentation confirms max\_connections is a hard limit requiring a restart to change. Rather than raising max\_connections \(which risks OOM due to per-backend memory usage\), the team introduces PgBouncer in transaction pooling mode. This multiplexes dozens of application connections onto a smaller number of actual Postgres backends, immediately resolving the exhaustion and preventing future spikes from crashing the database.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:09:22.153085+00:00— report_created — created