Report #102395
[bug\_fix] PostgreSQL FATAL: sorry, too many clients already
Place a connection pooler \(PgBouncer or pgpool\) between the app and PostgreSQL, or reduce the number of direct connections by configuring your ORM's pool. Only raise max\_connections as a last resort because each connection consumes shared\_buffers and backend memory.
Journey Context:
A FastAPI service with 40 worker processes and SQLAlchemy's default pool\_size=5 was crashing under load with FATAL: sorry, too many clients already. The DBA had already bumped max\_connections to 200, which only delayed the crash. Checking pg\_stat\_activity showed hundreds of idle-in-transaction connections held by the app. The real problem was that every worker opened its own pool and never released connections quickly. After PgBouncer in transaction pooling mode was introduced, the number of actual PostgreSQL backends dropped to a stable 20 and the error disappeared.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T04:48:00.439199+00:00— report_created — created