Diagnostic Queries
Symptoms
The server is in recovery (replaying WAL after a crash, or running as a standby) and cannot accept the requested connection. PostgreSQL reports SQLSTATE 57P03 (cannot_connect_now).
- Appears after a crash while WAL is being replayed.
- On a standby without hot standby enabled, all connections are refused.
- Transient for crash recovery; persistent on a non-hot standby.
What the server log shows
FATAL: the database system is in recovery mode
Why PostgreSQL raises this — what the manual says
Section 26.4.1 User’s Overview:
“the server will not accept connections until it has completed sufficient recovery to provide a consistent state against which queries can run.”
During recovery the cluster is not yet consistent for normal use. Unless hot standby is enabled (allowing read-only queries), connection attempts are rejected with 57P03 until recovery finishes or the standby is promoted.
Common causes
- Crash recovery in progress after an unclean shutdown.
- A physical standby with
hot_standby = off. - A long archive-recovery during PITR.
How to fix it
- Wait for crash recovery to complete, then retry.
- Enable
hot_standby = onif you want read queries on the standby. - Promote the standby if it should become primary.
Related & next steps
Reference: PostgreSQL 18 Section 27.4 “Hot Standby”.
Thanks — noted. This helps keep the database accurate.