- Symptom
- FATAL: sorry, too many clients alreadyFATAL: remaining connection slots are reserved for roles with the SUPERUSER attributeFATAL: remaining connection slots are reserved for non-replication superuser connections (PostgreSQL 15 and older)
- Cause
- max_connections defaults to 100 with 3 slots held for superusers, while each serverless instance or reloaded module opens its own pool of several connections. PostgreSQL 16 changed the error wording and added reserved_connections for members of pg_use_reserved_connections.
- Fix
- Put a pooler in front for app traffic, cap each pool at a small max, and reuse one pool per process.
- Apply
import pg from 'pg' const g = globalThis export const pool = g.pgPool ?? new pg.Pool({ connectionString: process.env.DATABASE_URL, max: 3 }) g.pgPool = pool- Affected
- All PostgreSQL versions for the limit; message text changed in PostgreSQL 16 (September 2023)
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders