Report #90726
[bug\_fix] FATAL: sorry, too many clients already \(SQLSTATE 53300\)
Deploy PgBouncer or pgpool-II in transaction pooling mode between the application and PostgreSQL, and reduce the application's per-instance connection pool size to fit within the pooler's max\_client\_conn. Root cause: PostgreSQL's max\_connections \(default 100\) creates a hard ceiling on backend processes; without an external pooler, idle connections from application instances exhaust this limit despite low actual query throughput.
Journey Context:
You horizontally scaled your Node.js API to 10 instances, each with a connection pool of 20, and immediately hit 'sorry, too many clients already' on deploy. Checking pg\_stat\_activity shows 200 idle connections from previous deployments that never closed. You realize that PostgreSQL backends are heavyweight processes \(shared memory per connection\), not threads, and the default 100 limit is intentional to prevent OOM. Directly increasing max\_connections to 400 would risk shared memory exhaustion. Instead, you place PgBouncer in transaction pooling mode between the apps and Postgres. Now each Node instance thinks it has 20 connections, but PgBouncer multiplexes them onto only 20 actual PostgreSQL backends, supporting 1000\+ application threads without backend exhaustion. The error disappears and latency stabilizes.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:52:28.510742+00:00— report_created — created