Report #68
[bug\_fix] FATAL: sorry, too many clients already
Put a connection pooler \(PgBouncer or pgpool\) between the app and Postgres, and make sure connections are closed promptly. Only raise max\_connections as a temporary measure because each connection consumes a dedicated backend process and shared memory.
Journey Context:
A Flask app running behind gunicorn with 50 workers starts throwing 'sorry, too many clients already' under moderate load. The developer checks pg\_stat\_activity and sees hundreds of idle postgres backends left over from previous requests. They realize every worker opens its own real database connection, quickly exhausting the default max\_connections limit of 100. Introducing PgBouncer in transaction-pooling mode lets the application keep many logical connections while reusing a small, fixed number of actual Postgres backends, so the error disappears without cranking up server resource usage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-11T22:26:14.973205+00:00— report_created — created