Why Your AI Database Tool Says 'Too Many Connections'
Your AI database connector worked fine, then started failing with 'too many connections' or 'remaining connection slots are reserved' — especially on Supabase or Neon. What's actually happening, and why the fix is usually the pooler endpoint, not a bigger plan.
The connection worked all week. Now you're getting FATAL: too many connections for role or remaining connection slots are reserved for non-replication superuser connections or, on Supabase specifically, something that boils down to the same thing — and it feels like your database just stopped accepting your AI tool at all.
This isn't a query problem. It's a connection slot problem, and it's especially common on serverless Postgres.
Why serverless Postgres hits this fast
Supabase and Neon both run Postgres with a real, and often surprisingly small, cap on direct connections — sometimes as low as 20-60 on entry tiers. That's fine for a handful of app servers holding long-lived pooled connections. It's not fine for a pattern where every tool call, dashboard tab, and background job opens its own fresh connection to the same database.
AI database sessions make this worse than average, not because a single query needs more connections, but because a conversation runs several tool calls in quick succession — describe_table on two or three tables, then execute_sql — and if the layer in between (your MCP gateway, or a self-hosted server) isn't reusing connections, each of those calls can grab and hold its own slot for the duration of the request.
The fix almost nobody tries first: the pooler endpoint
Both Supabase and Neon ship a separate connection string specifically built for this — a pooler endpoint (PgBouncer under the hood) in transaction mode. It sits in front of the database and lets hundreds of short-lived clients share a much smaller number of real backend connections, handing a connection out only for the duration of a single transaction and returning it immediately after.
If your MCP gateway or self-hosted server is configured against the direct database connection string instead of the pooler one, that's very often the entire fix: swap the connection string, keep the credentials, done. No plan upgrade, no code change on the AI side, nothing about your queries needs to be different.
Check your database provider's dashboard for wording like "Connection pooling," "Transaction mode," or a second connection string next to the direct one — it's usually sitting right there, just not the one that got copied into the connector by default.
When it's not the pooler's fault
If you're already on the pooler and still hitting the limit, the more likely causes are:
- A gateway or client that isn't releasing connections after a tool call finishes — worth asking directly whether it pools and reuses connections, or opens a new one per request
- Multiple people/environments sharing one connection string — a shared staging credential used by three team members simultaneously adds up faster than any one person notices
- Genuinely outgrown the tier — if legitimate concurrent usage across your team regularly needs more slots than the plan allows, that's a real upgrade case, not a workaround case
How to tell this apart from other failures
- "Too many connections" / "remaining connection slots" → connection limit, fix the endpoint or the pooling behavior
- Query runs, then fails after a while → a timeout, not a connection limit — different layer, different fix
- "Daily request limit reached" → a plan-level usage cap on the gateway side, unrelated to the database's own connection count
- Connector shows no tools at all → a different class of problem entirely
They can all show up as "it just stopped working," but the fix for one does nothing for the others, so identifying which error you're actually looking at is worth the extra ten seconds before you touch anything.
Read-only MCP gateway that pools connections correctly against Postgres, Supabase, and Neon: mcpserver.design.
Related reading: