Prisma · sdk · fg-0285

Next.js dev server runs out of database connections because each hot reload creates a new PrismaClient

If you see FATAL: sorry, too many clients already while running next dev, the cause and the fix for Prisma are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
FATAL: sorry, too many clients already while running next devThe connection count in pg_stat_activity climbs each time a file is saved
Cause
Next.js re-evaluates modules on hot reload, so a module-level new PrismaClient() builds another client and pool each time. With Prisma 7 each pg adapter pool can hold up to 10 connections.
Fix
Cache the client on globalThis outside production.
Apply
const g = globalThis as unknown as { prisma?: PrismaClient } export const prisma = g.prisma ?? new PrismaClient({ adapter }) if (process.env.NODE_ENV !== 'production') g.prisma = prisma
Affected
Next.js dev mode with Prisma ORM 6 and 7, as of October 2026
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun