Prisma Connection Pool Exhausted on Vercel
Your v0-generated Next.js application deployed on Vercel exhausts the database connection pool under moderate traffic. Each serverless function invocation creates new Prisma client instances that open their own database connections, and these connections are not shared across function invocations. As traffic increases, the database rapidly hits its maximum connection limit.
PostgreSQL databases on services like Supabase, Neon, or PlanetScale have connection limits ranging from 20 to 200 depending on the plan. With Vercel's serverless functions each maintaining their own connection pool, even modest traffic of 50 concurrent requests can exhaust all available database connections.
When the pool is exhausted, new requests queue up waiting for a connection, leading to timeouts and 500 errors that cascade across the entire application.
Error Messages You Might See
Common Causes
- New PrismaClient on every request — each serverless function creates a new client instance instead of reusing a singleton
- No connection pooler configured — direct database connections without PgBouncer or Prisma Accelerate between the app and database
- Default pool size too large — Prisma's default connection_limit of 10 multiplied by concurrent functions overwhelms the database
- Connections not released — long-running queries or missing $disconnect() calls prevent connection recycling
- Preview deployments multiply connections — each Vercel preview deployment runs its own function instances, further multiplying connection usage
How to Fix It
- Use a Prisma singleton — implement the singleton pattern: store PrismaClient in globalThis to reuse across warm function invocations
- Enable Prisma Accelerate — use Prisma Accelerate as a connection pooler that sits between your app and database
- Use Supabase connection pooler — switch DATABASE_URL to use Supabase's built-in PgBouncer on port 6543
- Reduce pool size — set
connection_limit=3in DATABASE_URL to limit connections per function instance - Add connection timeout — set
pool_timeout=10in the connection string to fail fast instead of queueing indefinitely - Monitor connections — run
SELECT count(*) FROM pg_stat_activityto track active database connections
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
Why does Prisma exhaust connections on Vercel?
Each serverless function invocation can create a new PrismaClient with its own connection pool. Under load, hundreds of functions each opening multiple connections quickly exhaust the database limit.
What connection_limit should I set for Vercel?
Set connection_limit=3 or even 1 in your DATABASE_URL. With a pooler like PgBouncer or Prisma Accelerate, the pooler manages the actual database connections.
What is Prisma Accelerate?
Prisma Accelerate is a managed connection pooler and query cache. It sits between your serverless functions and database, managing a shared connection pool across all function instances.