Report #68151
[bug\_fix] FATAL: sorry, too many clients already \(max\_connections exceeded\)
Implement client-side connection pooling \(e.g., PgBouncer, HikariCP, sql.Pool\) rather than creating a new connection per request. If scaling vertically, carefully increase max\_connections in postgresql.conf \(requires restart\) while ensuring kernel SHMMAX and shared\_buffers can support the overhead, but pooling remains the architectural fix.
Journey Context:
The application worked in development but throws fatal errors immediately when traffic increases in production. Checking PostgreSQL logs reveals 'sorry, too many clients already'. Querying pg\_stat\_activity shows hundreds of idle connections from application instances that never close. The developer realizes each HTTP request opens a new database connection without using a pool. Implementing a connection pool \(like PgBouncer as a sidecar or using the driver's built-in pool\) causes idle connections to drop to a steady baseline and the errors disappear.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:52:30.037151+00:00— report_created — created