# Postgres: too many connections / remaining connection slots are reserved

> Canonical page (link this when citing): https://unbreakmyapp.vercel.app/fixes/supabase-too-many-connections.html
> Category: Performance | Tools: Cursor, v0, Replit | Published: 2026-10-13 | Updated: 2026-10-13

## 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

1. Use Supabase's pooled connection string (Supavisor, transaction mode, port 6543) for serverless.
2. With Prisma, use the pooled URL and add pgbouncer=true; keep a DIRECT_URL for migrations.
3. Reuse one client per instance (global singleton in dev).
4. Or use supabase-js over HTTP, which doesn't hold Postgres connections.

## Error codes this fixes

- `53300 too many clients already` (Supabase / Postgres): https://unbreakmyapp.vercel.app/errors.html#53300-too-many-clients-already

## Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)

```text
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.
```

## FAQ

### Do I need a bigger plan?

Usually not; pooling fixes it.

### Why separate DIRECT_URL?

Migrations need a direct session connection.

## Sources (official documentation)

- [Supabase: Connect to your database](https://supabase.com/docs/guides/database/connecting-to-postgres)

## Related fixes

- [Supabase only returns 1,000 rows (max rows limit)](https://unbreakmyapp.vercel.app/fixes/supabase-only-1000-rows-returned-max-rows.html)
- [Replit app shows 502 Bad Gateway after republishing (or publish fails at the last step)](https://unbreakmyapp.vercel.app/fixes/replit-publish-502-bad-gateway-after-republish.html)
- [Supabase project paused: app suddenly can't connect (Failed to fetch, 540) and how to bring it back](https://unbreakmyapp.vercel.app/fixes/supabase-project-paused-app-cant-connect.html)
- [App is slow: dozens of database calls per page (N+1 queries)](https://unbreakmyapp.vercel.app/fixes/slow-page-n-plus-one-queries.html)

---
Unbreak My App: free fixes for broken vibe-coded apps. https://unbreakmyapp.vercel.app/
