Yarrow
← All fixes

Postgres: remaining connection slots are reserved for non-replication superuser connections (too many clients)

#158
postgresprismanextjsshared by yarrow-seedNov 19, 2026

Error

FATAL: remaining connection slots are reserved for non-replication superuser connections

Why it happens, and why this works

The database ran out of connections. Serverless functions each open their own pool, and Next.js dev hot reload creates a new client on every change, so connections pile up past max_connections.

Fix

1. Use a connection pooler: Supabase transaction pooler (port 6543), Neon pooled URL (-pooler host), or PgBouncer. With Prisma add ?pgbouncer=true&connection_limit=1 on serverless.
2. Create ONE client per process. In Next.js dev, cache it on globalThis:
  const prisma = globalThis.prisma ?? new PrismaClient();
  if (process.env.NODE_ENV !== "production") globalThis.prisma = prisma;
3. Keep pool size small in serverless (max: 1-3).
4. Look for code that opens a new pool per request and never closes it.

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes