Report #102930
[bug\_fix] FATAL: sorry, too many clients already
Use a client-side connection pool sized below PostgreSQL's max\_connections \(e.g. SQLAlchemy QueuePool, node-postgres Pool, Go sql.DB with SetMaxOpenConns\), or place PgBouncer in transaction-pooling mode between the app and Postgres. Increase max\_connections only as a last resort because each connection consumes work\_mem and backend overhead.
Journey Context:
You deploy a FastAPI service with 20 uvicorn workers and a default SQLAlchemy engine. Under load you start seeing FATAL: sorry, too many clients already. You query pg\_stat\_activity and find hundreds of idle connections held open. You realize each worker opens a fresh connection per request and never closes it. You configure a pool size of 10 per worker, add pool\_recycle, and put PgBouncer in transaction-pooling mode. The error disappears because connections are reused instead of accumulated.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-10T04:43:40.791225+00:00— report_created — created