SQLSTATE 53300 is too_many_connections. PostgreSQL refused a new session because a connection limit was reached. Related messages can mention reserved slots or limits for a role or database. Establish which limit applies before increasing capacity: excessive pools, leaked sessions, and reconnect storms often exhaust slots unnecessarily.
Application pools are oversized across multiple replicas, workers, or serverless instances, so their combined maximum exceeds the database budget.
Connections are not returned after exceptions, or long-running and idle-in-transaction sessions keep scarce slots occupied.
A traffic burst, rolling deployment, or reconnect loop reaches the server limit, reserved-slot threshold, or a configured role or database connection limit.
How to fix it
Use an existing authorized administrative session or your provider's monitoring console. Read the complete server message, then inspect SHOW max_connections; and relevant reserved-slot, role, and database limits. Do not grant ordinary applications superuser access to consume emergency capacity.
Group sessions with SELECT datname, usename, application_name, state, COUNT(*) FROM pg_stat_activity GROUP BY datname, usename, application_name, state ORDER BY COUNT(*) DESC; Monitoring visibility depends on privileges. Compare the largest groups with expected application replicas.
Calculate the total potential connections across every pool and deployment replica, leaving operational headroom. Reduce excessive pool sizes, bound concurrent work, and ensure error paths release connections and end transactions before returning them to the pool.
Investigate sessions that remain idle in transaction and repair their owning workflow. Drain obsolete application instances deliberately. Do not terminate all idle sessions indiscriminately; they may belong to healthy pools, and termination can interrupt work.
Use bounded backoff for connection retries and evaluate a compatible connection pooler if concurrency demands it. Increase max_connections only after reviewing memory, workload, provider constraints, and restart requirements, then load-test the revised budget and monitor connection growth.