Independent technical referenceOfficial site
  • Software and digital services
  • Databases

57P01

PostgreSQL 57P01 admin_shutdown: session ended by operator

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 57P01 (admin_shutdown) when an administrator or platform action terminates your backend session via a fast server shutdown or pg_terminate_backend(). Check with your operator whether maintenance or session termination occurred and run pg_isready before reconnecting.

Safety first

Stop and check this first

  • Do not attempt Immediate Shutdown (SIGQUIT, which sends SIGKILL after 5 seconds) during normal maintenance, because it skips normal database shutdown processing and forces WAL replay recovery on next start-up.
  • Never use SIGKILL (kill -9) to shut down the PostgreSQL server or its backends; the official documentation warns that SIGKILL prevents the server from releasing shared memory and semaphores and leaves subprocesses uncoordinated.

Safe checks you can perform

  • Test whether the PostgreSQL server is accepting connections with pg_isready
  • Correlate the 57P01 timestamp with server shutdown or signaling logs
  • Verify that interrupted write transactions were rolled back and not blindly replayed

Leave these tasks to a qualified professional

  • Do not attempt this professional task: Use pg_cancel_backend for query cancellation and Smart Shutdown for planned drains
  • Do not attempt this professional task: Gate application reconnection on pg_isready and clean pool reset

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. Use pg_cancel_backend for query cancellation and Smart Shutdown for planned drains

    What they doHave the DBA and operations team use pg_cancel_backend(pid) (which sends SIGINT to cancel only the current query) instead of pg_terminate_backend(pid) when a session need not be disconnected, and use Smart Shutdown (SIGTERM to the supervisor) when existing sessions can finish normally.

    They must show youthe operational runbook command (pg_ctl stop mode or SQL signaling function) and the server log entries from the maintenance window.

    In writingthe shutdown mode policy, the roles granted pg_signal_backend, and the grace period before Fast Shutdown is used.

  2. Gate application reconnection on pg_isready and clean pool reset

    What they doHave the engineering team configure the connection pool and worker processes to evict connections closed with 57P01, wait for readiness checks (such as pg_isready returning 0) with bounded backoff, and replay only idempotent or verified uncommitted transactions.

    They must show youthe pool eviction log on 57P01, the readiness check exit code 0 test, and retry backoff settings.

    In writingthe reconnection backoff parameters and the idempotency check used before replaying interrupted writes.

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. Test whether the PostgreSQL server is accepting connections with pg_isready

    Tools required

    Who:
    You, your developer, or your platform administrator from a client host.
    How:
    Run pg_isready with your target host and port (default timeout is 3 seconds, no password required) and inspect the shell exit status.
    Result that matters:
    Whether pg_isready returns exit status 0 (accepting connections), 1 (rejecting connections), or 2 (no response).
    If pg_isready returns 0 while only one session saw 57P01, that confirms the server remained online and points to an individual session termination via pg_terminate_backend or SIGTERM.
    If pg_isready returns 1 or 2 across the cluster, that indicates the server is shutting down, restarting, or undergoing maintenance.
    Evidence to keep:
    Record the exact pg_isready output line, exit status code, and UTC timestamp.

    Never supply production passwords on the command line when running pg_isready; the utility does not require a user name or password to obtain server status.

    Evidence: PostgreSQL server shutdown · PostgreSQL 18 pg_isready

  2. Correlate the 57P01 timestamp with server shutdown or signaling logs

    Tools required

    Who:
    Your DBA or hosting support reviewing the PostgreSQL server log and maintenance schedule.
    How:
    Inspect the server log at the exact timestamp of 57P01 for fast shutdown request messages or administrator signaling on the backend PID, redacting any connection strings or personal data before sharing.
    Result that matters:
    Whether the log records a server-wide Fast Shutdown signal or a single backend exit triggered by operator action.
    If the server log shows a Fast Shutdown sequence at that timestamp, that confirms a cluster stop or restart aborted all active transactions simultaneously.
    If only the single backend PID logged a termination by administrator command while other backends continued in pg_stat_activity, that isolates a targeted pg_terminate_backend call.
    Evidence to keep:
    Save the redacted server log lines with the backend PID and timestamp alongside any change ticket ID.

    Do not attempt to restart or signal the postgres supervisor process while checking logs; keep the investigation read-only.

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

  3. Verify that interrupted write transactions were rolled back and not blindly replayed

    No special tools

    Who:
    Your developer reviewing the application error handler and database state after reconnecting.
    How:
    Check how the application reacted to SQLSTATE 57P01 on in-flight transactions and verify with a read-only SELECT whether the interrupted unit of work committed before the signal arrived.
    Result that matters:
    Whether the open transaction was aborted cleanly by the server exit and whether the client discarded the dead connection handle.
    If the read-only query shows the changes are absent, that confirms SIGTERM aborted the uncommitted transaction as documented for Fast Shutdown and backend termination.
    If the changes are present, that indicates COMMIT completed just before the session was terminated and rules out re-running non-idempotent writes.
    Evidence to keep:
    Keep the client error timestamp, the backend PID, and the read-only verification query result.

    Evidence: PostgreSQL 18 Appendix A: Error Codes · PostgreSQL server shutdown

Still not solved

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

Virtual technician

Does 57P01 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

  • admin_shutdown
  • PostgreSQL 57P01
  • SQLSTATE 57P01

What it means

Appendix A assigns 57P01 to admin_shutdown in Class 57, Operator Intervention. PostgreSQL emits this code when a backend process receives SIGTERM either because the supervisor postgres process entered Fast Shutdown mode (SIGINT) or because an administrator or privileged role called pg_terminate_backend() (or sent SIGTERM directly to that child backend), causing the session to abort its current transaction and exit promptly. Receiving 57P01 only confirms an external administrative signal ended that connection and never proves by itself that the SQL query was defective or that the whole database server crashed.

Warnings and stop conditions

  • Mediumsource verified

    Do not attempt Immediate Shutdown (SIGQUIT, which sends SIGKILL after 5 seconds) during normal maintenance, because it skips normal database shutdown processing and forces WAL replay recovery on next start-up.

    Evidence: PostgreSQL server shutdown

  • Highsource verified

    Never use SIGKILL (kill -9) to shut down the PostgreSQL server or its backends; the official documentation warns that SIGKILL prevents the server from releasing shared memory and semaphores and leaves subprocesses uncoordinated.

    Evidence: PostgreSQL server shutdown

Symptoms and causes

Probable causes · in order

  • Fast server shutdown initiated for maintenance, restart, or failoverCommon

    When the supervisor postgres process receives SIGINT (Fast Shutdown mode via pg_ctl or service stop), the server disallows new connections and sends SIGTERM to all existing server processes so they abort open transactions and exit.

    Evidence: PostgreSQL 18 Appendix A: Error Codes · PostgreSQL server shutdown

  • Targeted session termination via pg_terminate_backend or SIGTERMCommon

    A superuser, a member of the backend's role, or a role granted pg_signal_backend can call pg_terminate_backend(pid) or send SIGTERM to a single child process while leaving all other sessions running.

    Evidence: PostgreSQL server shutdown · PostgreSQL 18 system administration functions

  • Automated platform or DBA cleanup of a blocking or long-running backendPossible

    Operators and managed database control planes invoke pg_terminate_backend using the pid from pg_stat_activity to clear sessions holding locks or lingering during a deployment window.

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

Sources and technical references

  1. 1

    PostgreSQL 18 Appendix A: Error Codes

    PostgreSQL Global Development Group · 2026 · official_doc

  2. 2

    PostgreSQL server shutdown

    PostgreSQL Global Development Group · 2026 · official_doc

Sources: PostgreSQL 18 Appendix A: Error Codes · PostgreSQL server shutdownreviewed 2026-10-19 · verified

Was this entry useful?