Report #37026
[bug\_fix] FATAL: sorry, too many clients already
Configure a connection pooler \(PgBouncer in transaction mode\) between the application and Postgres, or reduce the application-side pool size so that \(pool\_size × instance\_count\) < max\_connections. Alternatively, raise max\_connections in postgresql.conf if memory permits, but a pooler is preferred to avoid backend process exhaustion.
Journey Context:
A Node.js service running on 10 Kubernetes pods suddenly fails health checks after a scale-up event. Logs show FATAL: sorry, too many clients already. The developer checks SELECT count\(\*\) FROM pg\_stat\_activity; and sees 100 idle connections—the default max\_connections. Each pod defaults to a pool size of 10, so 10×10=100 exhausts the limit, leaving no slot for the health-check probe or superuser. The developer considers raising max\_connections to 200, but documentation warns each backend consumes shared memory. Instead, they introduce PgBouncer in transaction-pooling mode \(which allows thousands of client connections to multiplex over a small number of actual Postgres backends\), and set the app pool size to a conservative 5. The error disappears because PgBouncer queues excess connections rather than forwarding them to the already-saturated Postgres backend.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T16:37:31.633415+00:00— report_created — created