Supabase Too Many Connections Error
Quick Answer
Each serverless function creates a new database connection. Without pooling, you quickly exceed Supabase's connection limit (60 on free tier). Start with "Switch to connection pooling" before making broader code changes.
You're in the right place if...
- !'remaining connection slots are reserved'
- !Random 500 errors under load
- !App becomes unresponsive
Why this happens
Each serverless function creates a new database connection. Without pooling, you quickly exceed Supabase's connection limit (60 on free tier).
Fix
Switch to connection pooling
Use the pooled connection string (port 6543, not 5432):
# Use pooled connection string: # Supabase → Settings → Database → Connection string # Choose 'Connection pooling' mode DATABASE_URL=postgresql://postgres.[ref]:[password]@aws-0-[region].pooler.supabase.com:6543/postgres
Prevent this next time
Always use port 6543 (pooled) for serverless deployments. Use port 5432 (direct) only for long-running servers.
Frequently Asked Questions
Instead of each request opening its own database connection, a pooler shares a small number of connections across all requests.
Yes for serverless (Vercel, Cloudflare Workers). Optional for long-running servers (Railway, DigitalOcean).
Related fixes
Weekly Newsletter
Get next week's fix before you need it.
Join developers getting weekly vibe coding tips, error fixes, and tool updates.
Subscribe on Substack →