Report #87485
[bug\_fix] FATAL: sorry, too many clients already \(SQLSTATE 53300\)
Implement a connection pool \(e.g., PgBouncer in transaction mode, or application-side pool like HikariCP/pg-pool\). The root cause is unbounded connection creation exceeding PostgreSQL's max\_connections \(default 100\). Simply raising max\_connections is a temporary fix that consumes memory \(approx 10-20MB per connection\) and can hit kernel limits.
Journey Context:
You deploy a new microservice with 20 instances, each configured with 10 max connections in the driver \(no actual pooling\). Within minutes, the app logs show 'FATAL: sorry, too many clients already'. Checking pg\_stat\_activity reveals 100 connections all from your service, all idle or active. You realize each instance creates 10 raw connections on startup, exhausting the default 100 limit. You consider raising max\_connections to 500, but read that each connection uses significant memory. Instead, you install PgBouncer in transaction pooling mode, set the pool size to 20, and configure the app to connect through it. The error disappears and connection count stays low.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:25:57.410885+00:00— report_created — created