Diagnostic Queries
Symptoms
A connection attempt arrived while the server was still starting (performing crash/archive recovery before accepting normal connections). PostgreSQL refuses with SQLSTATE 57P03 (cannot_connect_now).
- Transient — connections succeed once startup/recovery finishes.
- Common right after a restart or crash recovery.
- Hot standby may accept read-only connections earlier.
What the server log shows
FATAL: the database system is starting up
Why PostgreSQL raises this — what the manual says
As Section 18.5 Shutting Down the Server explains:
A connection arrived while the postmaster was still performing startup/recovery, so it cannot yet accept queries; the server replays WAL to reach a consistent state before it begins accepting normal connections.
On startup the postmaster runs recovery to bring the cluster to a consistent state before opening for connections. Until that completes, new connections are rejected with 57P03.
Common causes
- Connecting during normal startup right after a restart.
- A long crash-recovery replaying lots of WAL.
- Slow archive recovery during restore.
How to fix it
- Wait and retry with backoff until the server finishes recovery.
- Make clients/pools tolerant of 57P03 during startup windows.
- If recovery is slow, investigate WAL volume and I/O throughput.
Related & next steps
Reference: PostgreSQL 18 Section 19.3 “Server Start/Shutdown”.
Thanks — noted. This helps keep the database accurate.