Fix Supabase 'Max Connection Reached' (Supavisor)
To fix Supabase max connection reached errors, stop opening direct connections from serverless functions, route them through the Supavisor transaction pooler, and hunt down idle-in-transaction connections with one query.
Last updated: 2026-10-10 To fix "max connection reached" in Supabase: route your app through the Supavisor transaction pooler (port 6543) instead of direct connections, keep client-side pools tiny, and kill or fix the idle-in-transaction connections holding slots hostage. The full diagnosis and the exact steps follow — most apps are fixed in under 30 minutes without upgrading anything. What the error looks like The failure arrives in a few different costumes depending on where the limit bites: FATAL: max clients reached in session mode - max clients are limited to pool_size: 15 FATAL: sorry, too many clients already FATAL: remaining connection slots are reserved for non-replication superuser connections The first one comes from Supavisor itself — your pooler is full. The second and third come from Postgres directly — your database has hit max_connections , which means clients are connecting past the pooler, or the pooler is sized too large relative to the database. The distinction matters, because the fix is different. Why it happens Supabase gives you two doors into Postgres: a direct connection (port 5432 on db.<project-ref>.supabase.co ) and the Supavisor pooler ( aws-0-<region>.pooler.supabase.com , port 6543 for transaction mode, 5432 for session mode). Direct connections are capped low — around 60 on most plans — because every one of them is a real Postgres backend process eating memory. Serverless functions and long-running processes are the classic killers. Each cold start or each new instance of your backend opens its own pool, and drivers like Prisma default their pool size to something like num_cpus * 2 + 1 . On a container host that reports the host's CPU count, one app instance can quietly grab every slot. Worse, connections that finish a request but…