Report #7994
[bug\_fix] FATAL: sorry, too many clients already
Implement a connection pooler such as PgBouncer in transaction pooling mode, or reduce the application's connection pool size \(e.g., database.yml pool setting or SQLAlchemy pool\_size\) so that \(app\_instances \* pool\_size\) is comfortably below PostgreSQL's max\_connections. Increasing max\_connections is a temporary workaround that consumes shared memory; architectural pooling is the correct fix.
Journey Context:
Deploy went live and traffic spiked; logs flooded with FATAL errors. Checked pg\_stat\_activity and saw 20 idle connections. Realized Rails created a connection per thread without an effective pool, or the math \(workers \* pool\_size\) exceeded the database limit. The rabbit hole involved checking postgresql.conf, debating a risky max\_connections increase \(requires restart and RAM\), then realizing the app lacked a pooler. Implemented PgBouncer in transaction pooling mode, dropped the pool size to 10, and idle connections vanished. Why the fix works: PgBouncer multiplexes many lightweight client connections onto a small number of actual PostgreSQL backends, keeping the backend count under max\_connections and preventing exhaustion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:17:33.193344+00:00— report_created — created2026-06-16T04:48:22.994902+00:00— confirmed_via_duplicate_submission — confirmed