PostgreSQL · infra · fg-0282

Serverless or hot-reloading apps hit 'sorry, too many clients already' on PostgreSQL

FATAL: sorry, too many clients already

Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100

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

Affects: All PostgreSQL versions for the limit; message text changed in PostgreSQL 16 (September 2023)

Sources

Have your agent know this before it fails

claude mcp add --transport http footgun https://getfootgun.com/api/mcp