Diagnostic Queries
Symptoms
A role hit its per-role connection limit set by ALTER ROLE … CONNECTION LIMIT. PostgreSQL refuses the new connection with SQLSTATE 53300 (too_many_connections).
- The role’s active connections reached its CONNECTION LIMIT.
- New connections for that role are rejected.
- Other roles may still connect normally.
What the server log shows
FATAL: too many connections for role "app_user"
Why PostgreSQL raises this — what the manual says
As the ALTER ROLE reference (Parameters) explains:
The role has reached the maximum number of concurrent connections set by its CONNECTION LIMIT (ALTER ROLE name CONNECTION LIMIT n); raise the limit or wait for some of the role’s existing sessions to disconnect.
Each role can carry a per-role cap on concurrent sessions. When the role’s active connection count reaches that cap, PostgreSQL rejects further logins for that role with 53300, even if the cluster-wide limit has room.
Common causes
- The role’s CONNECTION LIMIT is set too low for the workload.
- Connection leaks holding sessions open.
- A surge in concurrent clients using that role.
Relevant GUC parameters
| Parameter | Default | Effect |
|---|---|---|
max_connections |
100 | Cluster-wide cap; the per-role limit applies on top of it. |
How to fix it
- Raise the limit:
ALTER ROLE app_user CONNECTION LIMIT 200;. - Use a connection pooler (PgBouncer) to bound and reuse connections.
- Find and fix connection leaks in the application.
Diagnostic query
SELECT rolname, rolconnlimit FROM pg_roles WHERE rolname = 'app_user';
Compare the limit against current connections in pg_stat_activity for that role.
Related & next steps
Reference: PostgreSQL 18 — ALTER ROLE.
Thanks — noted. This helps keep the database accurate.