Report #6255
[bug\_fix] PostgreSQL "FATAL: sorry, too many clients already" or connection slot reservation errors
The application is exhausting max\_connections \(default 100\) by creating connections without adequate pooling, or the product of \(application instances × pool size\) exceeds the limit. The root fix is to introduce a connection pooler like PgBouncer \(in transaction or statement pooling mode\) between applications and Postgres, allowing many application-side connections to multiplex through a small, fixed set of actual Postgres connections. Alternatively, reduce per-instance pool sizes or increase max\_connections \(with caution, as each connection consumes shared memory\).
Journey Context:
You deploy a new microservice with 10 Kubernetes replicas, each configured with a connection pool of 20. After the 5th replica starts, new requests fail with "sorry, too many clients already". Checking pg\_stat\_activity reveals 100 idle connections, all from the new service. You consider raising max\_connections to 500, but your DBA warns that each connection uses ~10MB of shared memory and could cause OOM. You instead deploy PgBouncer as a sidecar in transaction pooling mode, configuring it with a max\_client\_conn of 1000 but only 20 server connections to Postgres. The application connects to PgBouncer instead of Postgres directly. The "too many clients" errors disappear, and pg\_stat\_activity shows a stable 20 connections regardless of application load.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:39:34.940176+00:00— report_created — created