Report #54640
[bug\_fix] FATAL: sorry, too many clients already \( connection slots reserved \)
Place a connection pooler \(PgBouncer or Pgpool-II\) between the application and Postgres, or reduce the application's pool size to fit within Postgres \`max\_connections\`. The root cause is that each Postgres connection forks a heavy backend process; defaults \(100\) are quickly exhausted by horizontally scaled apps that open raw connections per worker.
Journey Context:
A developer deploys a Node.js API with 4 instances, each using a connection pool of 30. In staging \(single instance\) it works, but in production the fourth instance fails to start, logging \`FATAL: sorry, too many clients already\`. The developer queries \`pg\_stat\_activity\` and sees hundreds of idle connections from previous app restarts that weren't closed fast enough. They initially try raising \`max\_connections\` to 500, but Postgres memory usage spikes and the OOM killer intervenes. Realizing that each connection consumes several MB of shared memory, they instead introduce PgBouncer in transaction-pooling mode. They set the app's pool size to 10 and PgBouncer's \`default\_pool\_size\` to 20. Now 100 app workers share only 20 actual Postgres connections, eliminating the error without memory pressure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:12:40.080904+00:00— report_created — created