Report #44585
[bug\_fix] FATAL: sorry, too many clients already
The root cause is aggregate connection count \(application processes × pool size\) exceeding max\_connections. The fix is to introduce an external connection pooler \(PgBouncer in transaction mode\) to multiplex many application connections over few server connections, rather than simply raising max\_connections which consumes excessive memory per connection \(work\_mem, maintenance\_work\_mem allocations\).
Journey Context:
You deploy a Node.js cluster with 8 workers, each using a connection pool of 20, to a production server with PostgreSQL max\_connections=100. Under load, users see 'sorry, too many clients already'. You check SELECT count\(\*\) FROM pg\_stat\_activity; showing 100 active connections, with many in idle state. You raise max\_connections to 200, but under load the kernel OOM killer terminates PostgreSQL because each connection allocates work\_mem \(4MB default\) for sorts. You eventually install PgBouncer, configure it in transaction pooling mode with max\_client\_conn=1000 and default\_pool\_size=20, allowing your 160 Node.js connections to share just 20 actual PostgreSQL connections, eliminating the errors and stabilizing memory usage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:18:15.499965+00:00— report_created — created