Diagnostic Queries
Symptoms
A session was terminated by an administrator command (e.g. pg_terminate_backend() or a fast shutdown). PostgreSQL raises SQLSTATE 57P01 (admin_shutdown).
- The connection was terminated by an admin action.
- Common during fast shutdown or manual session termination.
- Distinct from a crash.
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:
“pg_cancel_backend and pg_terminate_backend send signals (SIGINT or SIGTERM respectively) to backend processes identified by process ID.”
Administrative actions — pg_terminate_backend(), a fast/immediate shutdown, or signals — ask backends to exit. The affected session ends and reports 57P01.
Common causes
- An admin ran
pg_terminate_backend(pid). - A fast shutdown of the server.
- Management tooling recycling connections.
How to fix it
- Reconnect; this is an intentional termination, not an error in your query.
- If unexpected, check who/what terminated the session (logs, automation).
- Make the application resilient to administrative disconnects.
Related & next steps
Reference: PostgreSQL 18 Section 9.28 “System Administration Functions”.
Thanks — noted. This helps keep the database accurate.