FATAL: sorry, too many clients already / remaining connection slots are reserved for non-replication superuser connections

PostgreSQL reached max_connections.

Seen on: PostgreSQL

Meaning

Each connection is a process using memory, so max_connections is modest (default 100). Serverless functions, many app instances and missing pooling exhaust it quickly.

Common causes

  • No connection pooling (serverless, many workers)
  • Connection leaks
  • Idle connections never closed
  • Pool sizes × instances > max_connections

⚡ Quick fix

  1. Use a pooler (PgBouncer, RDS Proxy, Supabase pooler)
  2. Reduce pool sizes per instance
  3. Close idle connections (idle_session_timeout)

Detailed fix by platform

PostgreSQL

  1. SELECT usename, application_name, state, count(*) FROM pg_stat_activity GROUP BY 1,2,3 ORDER BY 4 DESC;

How to diagnose

  1. Usage — Who holds connections?
  2. Pooling — Is a pooler in front?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.