the database system is shutting down

SQLSTATE 57P03 condition cannot_connect_now class 57 — Operator Intervention severity FATAL
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 30 May 2025 · Reproduced live with the SQL on this page.

Symptoms

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

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

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”.