Fix: Supabase Connection Pool Exhausted
Quick Answer
Use Supabase's connection pooler (Supavisor) instead of direct connections. In your connection string, change port 5432 to port 6543 and add ?pgbouncer=true to the connection URL.
Quick Fix Summary
| Issue | Too many database connections |
| Fastest fix | Switch to connection pooling |
| Use this page if | Error: remaining connection slots are reserved |
Symptoms
- !Error: remaining connection slots are reserved
- !FATAL: too many connections for role
- !App works but becomes unresponsive under load
- !Random 500 errors on database queries
Step-by-Step Fix
Switch to connection pooling
In Supabase Dashboard > Settings > Database > Connection string, switch to 'Connection pooling' mode. Copy the new connection string that uses port 6543 instead of 5432.
Use the pooler URL in serverless functions
Vercel/Cloudflare serverless functions create a new connection per request. Without pooling, 10 concurrent requests = 10 connections. The pooler reuses connections.
Close connections properly
If using Prisma, add: datasources { db { url = env("DATABASE_URL") } } with the pooler URL. Add '?pgbouncer=true&connection_limit=1' to the URL.
Check your plan limits
Free plan: max 60 connections. Pro: max 200. Check current usage in Supabase Dashboard > Database > Database health.
Frequently Asked Questions
Each serverless function invocation opens a new database connection. Under load, you quickly exceed the limit. Connection pooling solves this by reusing connections.
Yes, for serverless deployments (Vercel, Cloudflare Workers, Netlify). For long-running servers (Railway, DigitalOcean), direct connections are fine.
Related
Weekly Signals
Get the next fix, switch, or warning before it hits your build.
Join builders getting the community signals, fix patterns, and tool shifts that matter before they show up everywhere else.
Follow the signals →