Report #74400
[bug\_fix] FATAL: sorry, too many clients already
Implement a connection pooler \(e.g., PgBouncer\) in transaction pooling mode, or reduce the application connection pool size to fit within PostgreSQL's max\_connections. Simply increasing max\_connections is a temporary fix that consumes more memory \(approx. 400KB\+ per connection\) and should be avoided.
Journey Context:
Under production load, the application suddenly starts throwing connection errors. Checking pg\_stat\_activity reveals hundreds of idle connections, far exceeding the typical active query count. Investigation shows each application server instance is opening direct connections to PostgreSQL without pooling, exhausting the default 100 max\_connections. The DBA implements PgBouncer between the app and Postgres, configuring it in transaction pooling mode. This allows the application to maintain many logical connections while PgBouncer multiplexes them onto a small number of actual PostgreSQL backend processes, eliminating the error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:28:47.943643+00:00— report_created — created