Report #13955
[bug\_fix] FATAL: sorry, too many clients already \(max\_connections exceeded\)
Implement a connection pooler \(PgBouncer or pgpool\) in transaction pooling mode, or reduce the application-side connection pool size. The root cause is PostgreSQL's max\_connections \(default 100\) being exhausted because each application worker holds a persistent connection; a pooler multiplexes many client connections onto fewer server connections, releasing the server slot immediately after each transaction.
Journey Context:
A horizontally-scaled web service with 200 Kubernetes pods starts throwing "sorry, too many clients already" immediately on deploy. The developer checks pg\_stat\_activity and sees 100 idle connections, all from the new pods. They increase max\_connections to 200 in postgresql.conf, but now the OOM killer terminates Postgres during peak load because each connection consumes shared memory. Realizing the pods don't need 200 persistent connections but rather 200 concurrent workers that can share a pool, they deploy PgBouncer with pool\_mode=transaction, max\_client\_conn=200, and default\_pool\_size=20. They repoint application connection strings from port 5432 to 6432 \(PgBouncer\). The errors stop because PgBouncer assigns a PostgreSQL backend only for the duration of a transaction, then releases it, keeping the actual backend count well below max\_connections while accommodating all 200 application clients.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:16:19.822578+00:00— report_created — created