Prisma · sdk · fg-0285

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

FATAL: sorry, too many clients already while running next dev

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

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

Affects: Next.js dev mode with Prisma ORM 6 and 7, as of October 2026

Sources

Have your agent know this before it fails

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