Report #64554
[bug\_fix] FATAL: sorry, too many clients already
Implement a connection pooler \(e.g., PgBouncer in transaction mode\) or use the application driver's built-in pool with a max size lower than Postgres's max\_connections. Do not just increase max\_connections without pooling, as each connection consumes significant memory and process slots. The root cause is the application opening a new physical connection for every request without closing it or returning it to a pool, eventually exhausting the Postgres backend limit.
Journey Context:
You deploy a new Node.js service to production, connecting to your RDS Postgres instance. Everything works fine during testing with 5 users. As traffic ramps up to 100 concurrent users, suddenly all requests start failing with "FATAL: sorry, too many clients already". You check \`SELECT \* FROM pg\_stat\_activity;\` and see 100 idle connections from your app server's IP, all in "idle" state. You realize you used \`pg.Client\` in a loop without calling \`client.end\(\)\`, and you have no connection pool configured. You initially try to fix it by bumping \`max\_connections\` to 500 in postgres.conf, but the error returns a week later under higher load. You then implement PgBouncer in transaction pooling mode, limiting the actual Postgres backends to 50, while your app opens 1000 logical connections to PgBouncer. This isolates the connection count from the app and solves the root cause: the lack of intermediate pooling.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:50:14.875204+00:00— report_created — created