Report #85769
[bug\_fix] FATAL: sorry, too many clients already
Deploy PgBouncer \(or pgpool\) in transaction pooling mode to multiplex thousands of application connections onto a small, fixed pool of PostgreSQL backends \(e.g., pool\_size=20\). Alternatively, increase max\_connections cautiously \(requires memory for each backend process ~5-10MB\). Root cause: PostgreSQL uses a process-per-connection model; each backend consumes significant RAM and OS resources, so max\_connections \(default 100\) protects system stability.
Journey Context:
The application suddenly returns 500s for every request. Logs show 'FATAL: sorry, too many clients already'. The developer runs SELECT count\(\*\) FROM pg\_stat\_activity; and sees 100 active connections, mostly idle. They increase max\_connections to 200 in postgresql.conf and restart, but hit the limit again during the next traffic spike. Checking memory, they realize each connection uses ~10MB, threatening OOM. They investigate PgBouncer, installing it with pool\_mode=transaction and default\_pool\_size=20. They route the application to PgBouncer \(port 6432\) instead of PostgreSQL directly. The 'too many clients' error disappears because PgBouncer maintains only 20 actual PostgreSQL connections, recycling them between the thousands of short transactions from the app.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:33:06.128490+00:00— report_created — created