Short answer
Your database has a connection limit set by its compute size, and something is opening more connections than it allows. In serverless or edge functions, connect through Supabase’s shared pooler in transaction mode, create the client once, and set its pool to 1 connection. If you’re already pooling and still at the limit, a larger compute size allows more connections.
Why the connections run out, and the fix
01
The database is at its connection limit
“This error usually occurs when the database reaches the maximum number of connections allowed based on the compute add-on.” Supabase, Remaining connection slots are reserved
Each compute size allows a set number of connections. Check how many are in use in the dashboard before changing anything, so you know whether the fix is fewer connections or a bigger instance.
02
Serverless functions connect directly
“Use it for serverless and edge functions, which open many short-lived connections.” Supabase, Connect to your database
Each warm instance of a function on Vercel, Netlify or Supabase Edge Functions can hold its own connections. Use the transaction pooler connection string from the Connect dialog instead of the direct one.
03
The client library opens too many per instance
“Library defaults are too high for serverless. Postgres.js defaults to 10 connections.” Supabase, Connect to your database
A database library keeps its own pool. Create the client once, outside the request handler, set its pool to 1 connection in serverless code, and turn off prepared statements, which the shared pooler doesn’t support in transaction mode. With Prisma, the matching setting is connection_limit.
Checked against the vendor’s docs on : Supabase docs: Connect to your database; Supabase: Remaining connection slots are reserved.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.See scope and start
Related: Vercel function timeout (504) · Supabase project paused · Backend and API development