FluentDBFluentDB
PostgreSQL errors

PostgreSQL: remaining connection slots are reserved

FATALSQLSTATE 53300too_many_connections
FATAL: remaining connection slots are reserved for non-replication superuser connections

The connections available to normal roles are exhausted, and the only slots left are the ones Postgres reserves for superusers. Reduce your connection count with pooling, or raise max_connections.

What this error means

Postgres reserves a few connection slots (superuser_reserved_connections) so an administrator can always get in, even when the server is busy. When non-superuser connections fill every remaining slot, new ones get this error while the reserved slots stay untouched.

It is effectively the same root problem as 'too many clients already': you are at the connection ceiling, usually from a leak or a missing pool.

How to fix it

01

You are at the connection ceiling

Pool connections and lower the app pool size so you stay below the non-reserved limit.

02

You genuinely need more slots

Raise max_connections and restart Postgres.

sql
ALTER SYSTEM SET max_connections = 200;
-- then restart Postgres
03

Idle sessions are holding slots

Terminate idle connections to recover them immediately.

sql
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE state = 'idle';

How to avoid it next time

  • Always run application traffic through a pooler, so a small number of real connections serve many clients.
  • Monitor connection counts and alert before you reach the ceiling.
Varies by version

Postgres 16 reworded this to "reserved for roles with the SUPERUSER attribute" and added a separate reserved_connections setting for reserving slots to non-superusers.

Frequently asked questions

Why are some slots reserved?

So a superuser can always connect to investigate, even when the server is saturated. superuser_reserved_connections controls how many.

Is this the same as 'too many clients already'?

Nearly. Both mean you hit the connection ceiling. This variant appears when only the superuser-reserved slots remain.

Stop struggling with SQL

Use FluentDB, the AI database client for macOS.