Independent technical referenceOfficial site
  • Software and digital services
  • Databases

53300

PostgreSQL 53300 too_many_connections: slot limit reached

Verified with sources2 sourcesReviewed Oct 19, 2026
Technician coming? See the 2 steps they must show you
Trace

Risk level

High

Professional inspection is recommended.

Urgency

High

Quick answer

PostgreSQL returns 53300 (too_many_connections) when all non-reserved connection slots for your role are full. Check pg_stat_activity from an existing admin session to see which application and state hold the slots before considering any change to max_connections.

Safety first

Stop and check this first

  • Never grant superuser privileges to application roles to use superuser_reserved_connections, and never raise max_connections on a primary server without setting the same or higher value on every standby server first.
  • Do not attempt to terminate internal PostgreSQL processes (such as autovacuum worker, checkpointer, walwriter, or background writer in pg_stat_activity) or use OS kill -9 to free connection slots.

Safe checks you can perform

  • Compare configured connection limits against reserved slots with SHOW
  • Group live backends in pg_stat_activity by application_name, usename, and state
  • Audit total connection pool maximums across all deployed application instances

Leave these tasks to a qualified professional

  • Do not attempt this professional task: Right-size connection pools and reclaim leaked idle sessions safely
  • Do not attempt this professional task: Review shared memory and standby settings before changing max_connections

What a technician must be able to justify

Technician visit

These are the steps they must carry out and show you. Tick them as they work: if steps are skipped, do not accept a part swap.

These are not instructions for opening or handling the equipment yourself. They are the checks that should support a technical conclusion.

  1. Right-size connection pools and reclaim leaked idle sessions safely

    What they doHave the engineering team cap application pool sizes or route clients through a transaction pooler so total client backends stay below max_connections minus reserved slots, and have the DBA use pg_terminate_backend(pid) only on verified leaked client backends identified in pg_stat_activity.

    They must show youthe pg_stat_activity connection count by state before and after pool resizing, plus the exact PIDs and state of any terminated leaked sessions.

    In writingthe new per-instance pool limit, the total connection budget across services, and the idle_in_transaction_session_timeout policy.

  2. Review shared memory and standby settings before changing max_connections

    What they doIf legitimate concurrent workload requires more slots after pooling, have the DBA calculate shared memory impact, verify that every standby server has max_connections set to the same or higher value than the primary, back up postgresql.conf, and schedule the server restart.

    They must show youthe SHOW max_connections output on both primary and standby servers, shared memory usage metrics, and reserved_connections settings.

    In writingthe primary and standby max_connections values, superuser_reserved_connections, reserved_connections, and the scheduled restart window.

Before accepting a part or repair

Nothing has been shown yet. Do not accept a part swap based on the code alone.

Follow these steps

Note: Follow the documented order. An error code identifies the affected system, but it does not prove by itself which part has failed.

  1. Compare configured connection limits against reserved slots with SHOW

    Tools required

    Who:
    Your DBA or an operator connected via a reserved or existing session.
    How:
    Run SHOW max_connections, SHOW superuser_reserved_connections, and SHOW reserved_connections (or read pg_settings) and compare the non-reserved ceiling with pg_stat_database.numbackends.
    Result that matters:
    The exact number of non-reserved slots available to normal roles (max_connections minus superuser_reserved_connections minus reserved_connections).
    If total numbackends across databases equals max_connections minus the reserved slots, that confirms normal roles have exhausted their allowed connection budget.
    If a large share of max_connections is assigned to reserved_connections or superuser_reserved_connections, that points to slot reservation leaving too few normal client slots.
    Evidence to keep:
    Record the exact numeric values returned by the three SHOW commands and the sum of numbackends from pg_stat_database.

    Never raise max_connections blindly or edit pg_hba.conf to trust during an outage; max_connections requires a server restart and increases shared memory allocation.

    Evidence: PostgreSQL connection settings · PostgreSQL 18 SHOW · PostgreSQL 18 cumulative statistics system

  2. Group live backends in pg_stat_activity by application_name, usename, and state

    Tools required

    Who:
    Your DBA or developer querying pg_stat_activity over a privileged or reserved connection.
    How:
    Query pg_stat_activity grouped by datname, usename, application_name, backend_type, and state, redacting any client secrets or personal data before exporting.
    Result that matters:
    Whether the slots are held by active queries, idle pooled connections, or sessions stuck in idle in transaction.
    If most rows for an application_name are in state idle or idle in transaction with old backend_start or xact_start timestamps, that confirms connection leaks or oversized pools rather than genuine compute demand.
    If rows are predominantly in state active with non-null wait_event_type = 'Lock', that indicates a lock bottleneck is piling up concurrent requests until slots run out.
    Evidence to keep:
    Save the grouped count table from pg_stat_activity with states, application names, and oldest xact_start timestamps.

    Do not attempt to free slots by terminating unknown backends or internal server processes; inspect backend_type and state read-only first.

    Evidence: PostgreSQL connection settings · PostgreSQL 18 cumulative statistics system

  3. Audit total connection pool maximums across all deployed application instances

    No special tools

    Who:
    Your developer or platform engineer reviewing deployment and pooler configurations.
    How:
    Multiply the number of running application containers or worker processes by each instance's maximum pool setting, without exposing connection passwords.
    Result that matters:
    Whether the combined client pool ceiling exceeds the non-reserved PostgreSQL slot count.
    If the combined application pool limit is higher than max_connections minus reserved slots, that confirms scale-out or deploy surge can trigger 53300 whenever traffic peaks.
    If the combined pool limit is well below the non-reserved slot limit, that rules out static pool sizing and isolates unpooled scripts, ad-hoc clients, or leaked connections.
    Evidence to keep:
    Keep a breakdown of each service's replica count, pool max setting, and total potential connections.

    Evidence: PostgreSQL 18 Appendix A: Error Codes · PostgreSQL connection settings

Still not solved

If the error persists, stop here. See what the technician must do and show you.

Virtual technician

Does 53300 still appear after these checks?

This guided flow uses the exact code and your answers to choose a test, an expected result and the next branch.

Where this code applies

A code is meaningful only inside the right product and version context.

Primary scope

System
Software and digital services
Brand
PostgreSQL
Product type
Databases

Known code variants

  • PostgreSQL 53300
  • SQLSTATE 53300
  • too_many_connections

What it means

Appendix A places 53300 (too_many_connections) in Class 53, Insufficient Resources. The server allows at most max_connections concurrent connections (typically 100 by default, set only at server start) while setting aside superuser_reserved_connections (default three) for superusers and reserved_connections (default zero) for roles with pg_use_reserved_connections. Once active connections reach max_connections minus the reserved slots, normal client logins are rejected with 53300. This code only reports that no slot was available for the requesting role and never proves by itself that the server hardware is undersized or that max_connections must be raised.

Warnings and stop conditions

  • Highsource verified

    Never grant superuser privileges to application roles to use superuser_reserved_connections, and never raise max_connections on a primary server without setting the same or higher value on every standby server first.

    Evidence: PostgreSQL connection settings

  • Highsource verified

    Do not attempt to terminate internal PostgreSQL processes (such as autovacuum worker, checkpointer, walwriter, or background writer in pg_stat_activity) or use OS kill -9 to free connection slots.

    Evidence: PostgreSQL 18 cumulative statistics system · PostgreSQL 18 system administration functions

Symptoms and causes

Probable causes · in order

  • Application connection pools or worker replicas exceeding non-reserved capacityCommon

    When the sum of maximum pool sizes across application instances plus background workers reaches max_connections minus superuser_reserved_connections and reserved_connections, new regular connections fail with 53300.

    Evidence: PostgreSQL 18 Appendix A: Error Codes · PostgreSQL connection settings

  • Leaked client sessions lingering in idle or idle in transaction statesCommon

    Unclosed client connections or sessions stuck in idle in transaction or idle in transaction (aborted) occupy backend slots in pg_stat_activity without doing active query work.

    Evidence: PostgreSQL connection settings · PostgreSQL 18 cumulative statistics system

  • Hung authentication attempts or blocked queries holding backends openPossible

    Clients stalling during authentication up to authentication_timeout (default one minute, 1m) or active queries waiting on locks prevent existing backends from disconnecting and freeing slots.

    Evidence: PostgreSQL connection settings · PostgreSQL 18 cumulative statistics system

Sources and technical references

  1. 1

    PostgreSQL 18 Appendix A: Error Codes

    PostgreSQL Global Development Group · 2026 · official_doc

  2. 2

    PostgreSQL connection settings

    PostgreSQL Global Development Group · 2026 · official_doc

Sources: PostgreSQL 18 Appendix A: Error Codes · PostgreSQL connection settingsreviewed 2026-10-19 · verified

Was this entry useful?