Report #67905
[bug\_fix] FATAL: sorry, too many clients already
Implement a connection pooler \(PgBouncer\) or reduce the application's connection pool size to fit within PostgreSQL's max\_connections minus superuser\_reserved\_connections. Do not simply raise max\_connections without accounting for per-backend memory usage \(~10MB\+ each\).
Journey Context:
A developer deploys a Node.js API with a default connection pool of 20, scaled to 10 instances, hitting a PostgreSQL with max\_connections=100. Under load, the app throws 'FATAL: sorry, too many clients already'. Investigating pg\_stat\_activity reveals hundreds of idle connections. The developer calculates 10 instances × 20 connections = 200, which exceeds the 100 limit. Considering raising max\_connections, the DBA warns of OOM killer risks due to per-process memory overhead. The developer introduces PgBouncer in transaction pooling mode, allowing 200\+ client connections while maintaining only 20 actual PostgreSQL backends, resolving the exhaustion without increasing max\_connections.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:27:28.385661+00:00— report_created — created