Fixes › Performance
Postgres: too many connections / remaining connection slots are reserved
Published
The error
FATAL: sorry, too many clients already / remaining connection slots are reserved
Why it happens
Serverless functions each open their own direct database connection, so traffic spikes exhaust Postgres's connection limit. ORMs like Prisma create a new pool per cold start.
How to fix it
- Use Supabase's pooled connection string (Supavisor, transaction mode, port 6543) for serverless.
- With Prisma, use the pooled URL and add pgbouncer=true; keep a DIRECT_URL for migrations.
- Reuse one client per instance (global singleton in dev).
- Or use supabase-js over HTTP, which doesn't hold Postgres connections.
Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)
We hit 'too many connections' on Supabase Postgres under load. Switch serverless code to the pooled connection string (transaction mode, port 6543), configure Prisma with pgbouncer=true and a separate DIRECT_URL for migrations, make the DB client a singleton, and list the env vars to update.
Error codes this fixes
53300 too many clients already(Supabase / Postgres)
FAQ
Do I need a bigger plan?
Usually not; pooling fixes it.
Why separate DIRECT_URL?
Migrations need a direct session connection.
Sources
Based on the official documentation:
Related fixes
- Supabase only returns 1,000 rows (max rows limit)
- Replit app shows 502 Bad Gateway after republishing (or publish fails at the last step)
- Supabase project paused: app suddenly can't connect (Failed to fetch, 540) and how to bring it back
- App is slow: dozens of database calls per page (N+1 queries)
Want the full checklist for this area? Get a Fix Kit ($29)
Featured slot available: reach thousands of vibe coders. Sponsor this week →
Get one new fix a week
Free newsletter: the newest breakages in Lovable, Bolt, Cursor, Replit and v0 apps, with paste-in fixes.
We only use your email to send the newsletter. Unsubscribe any time. See privacy.