Diagnostic Queries
Symptoms
A connection was refused because the server is still starting up (or performing crash recovery) and not yet ready to accept connections. PostgreSQL raises SQLSTATE 57P03 (cannot_connect_now).
- The server is in startup/recovery.
- Connections are temporarily refused.
- Common right after a restart or crash recovery.
What the server log shows
FATAL: the database system is starting up
Why PostgreSQL raises this — what the manual says
Section 18.3 Starting the Database Server:
“But a PostgreSQL server that might have to perform crash recovery at startup could take much longer to become ready.”
Before completing startup/recovery, the server cannot safely serve queries. It refuses connections with 57P03 until recovery finishes and it reaches a consistent, ready state.
Common causes
- The server is replaying WAL during crash recovery.
- A standby is still reaching a consistent recovery point.
- A recently restarted server still initializing.
How to fix it
- Wait and retry; recovery time scales with the amount of WAL to replay.
- Monitor the server log for “database system is ready to accept connections”.
- If recovery is very long, investigate WAL volume and checkpoint settings.
Related & next steps
Reference: PostgreSQL 18 Section 19.3 “Starting the Server”.
Thanks — noted. This helps keep the database accurate.