SQLSTATE 57P03 FATAL Class 57: Operator Intervention

cannot_connect_now the database system is shutting down — 57P03

PostgreSQL error "the database system is shutting down" (SQLSTATE 57P03): 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

A connection attempt arrived while the server was shutting down. PostgreSQL refuses new connections with SQLSTATE 57P03 (cannot_connect_now).

  • Seen during smart/fast shutdown or restart.
  • Existing sessions may be finishing or being terminated.
  • Transient until the server stops or restarts.

What the server log shows

FATAL:  the database system is shutting down

Why PostgreSQL raises this — what the manual says

Section 18.5 Shutting Down the Server:

“The server disallows new connections and sends all existing server processes SIGTERM, which will cause them to abort their current transactions and exit promptly.”

Once shutdown begins, the postmaster stops accepting new connections so it can drain or terminate existing ones and stop cleanly. New attempts during this window are rejected with 57P03.

Common causes

  • An operator initiated shutdown or restart.
  • Automated maintenance/deploy restarting the server.
  • Failover or orchestration stopping the instance.

How to fix it

  1. Retry after the restart completes; use exponential backoff.
  2. Coordinate deploys so clients expect brief unavailability.
  3. Front the database with a pooler that handles reconnects gracefully.

Related & next steps

Reference: PostgreSQL 18 Section 19.3 “Shutting Down the Server”.

Was this helpful?