Prisma · runtime error · P2024

P2024: Timed out fetching a new connection from the connection pool

what it looks like
PrismaClientKnownRequestError: Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 5)

What it means

Every connection Prisma may open is busy, or the database refused more. In Next.js this is almost always too many PrismaClient instances, or serverless functions each holding their own pool.

Common causes

  • new PrismaClient() in many files, or inside a request handler
  • next dev hot reload creating a fresh client on every change (no globalThis singleton)
  • Serverless functions connecting straight to Postgres instead of through a pooler

How to fix it

  1. Create PrismaClient once in lib/db.ts with the globalThis pattern and import db everywhere
  2. On serverless, use the provider's pooled connection string (Supabase port 6543 with ?pgbouncer=true, or Neon's -pooler host)
  3. Use a direct (non-pooled) URL as directUrl in schema.prisma, for migrations
prisma/schema.prisma
datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL") // pooled
  directUrl = env("DIRECT_URL")   // direct, used by migrate
}

works with Prisma ORM 6.19 · Next.js 16last verified

Prompt for Cursor or Claude Code

Prisma throws P2024 (connection pool timeout). Search the codebase for every new PrismaClient(), replace them with one globalThis singleton in lib/db.ts, and tell me whether DATABASE_URL is a pooled connection. If it isn't, show me the schema.prisma change for url + directUrl.

Not quite your error? Paste yours into the free VibeBoot Doctor or browse the Prisma error fixer.

next: skip the next one

Skip the debugging. The VibeBoot SaaS Starter ships with this already handled: one Prisma client in src/lib/db.ts, prisma generate on every build and install, and AGENTS.md rules that tell your agent never to create another client. Plus auth and Stripe on Next.js 16.4.3. $49, one-time.

14-day money-back guarantee · lifetime updates

$ fixed it? get the next one first

New fixes for what AI agents break, by email.

When we add a fix or a Cursor rule for a new Next.js, Auth.js, Prisma or Stripe break, it goes out in the VibeBoot newsletter. Free, occasional, unsubscribe in one click.

Subscribe free