SQLSTATE 57P01 FATAL Class 57: Operator Intervention

admin_shutdown terminating connection due to administrator command — 57P01

PostgreSQL error "terminating connection due to administrator command" (SQLSTATE 57P01): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

Symptoms

The session was forcibly terminated by an administrator (or by pg_terminate_backend()), or as part of a server operation. PostgreSQL raises SQLSTATE 57P01 (admin_shutdown) and the connection closes.

  • Unlike a cancel, the whole connection is dropped.
  • Often issued to clear a stuck or idle-in-transaction session.
  • The client must reconnect.

What the server log shows

FATAL:  terminating connection due to administrator command

Why PostgreSQL raises this — what the manual says

Section 9.28.2 Server Signaling Functions:

“Terminates the session whose backend process has the specified process ID.”

A terminate request signals the target backend to exit. The backend rolls back any open transaction and closes the connection, reporting 57P01 to the client. This also occurs during certain shutdown/restart scenarios.

Common causes

  • An admin ran pg_terminate_backend(pid).
  • A connection killed for being idle-in-transaction too long.
  • Server restart/failover dropping existing sessions.

How to fix it

  1. Reconnect and retry; make the application resilient to dropped connections.
  2. Investigate why the session was terminated (long idle, blocking others).
  3. Use connection pooling that transparently re-establishes sessions.

Related & next steps

Reference: PostgreSQL 18 Section 9.28 “System Administration Functions”.

Was this helpful?