FATAL: the database system is starting up means the PostgreSQL server process is running, but it is not ready for normal sessions yet. Almost always it is replaying WAL: after a crash, after an unclean shutdown, or on a standby that has not caught up enough to serve reads. The server refuses the connection with SQLSTATE 57P03 (cannot_connect_now). Nothing is lost. The question is how long the replay will take and whether anything stops it.
$ psql -h db1 -U app appdb
psql: error: connection to server at "db1" (10.0.0.11), port 5432 failed:
FATAL: the database system is starting up
Which message means what
All of these come from the connection startup code and depend on the state of the postmaster (postmaster.c). The wording changed between versions, which is why two servers in the same incident can show different texts.
the database system is starting up: the very first phase of startup. On PostgreSQL 13 and older, clients see this message for the whole WAL replay, both during crash recovery and on a standby that is not yet open for reads. On PostgreSQL 14, it still covers the whole of crash recovery.the database system is not yet accepting connectionswithDETAIL: Consistent recovery state has not been yet reached.: replay has started, but the data is not consistent yet. From PostgreSQL 14 you see this on a standby or during point-in-time recovery. From PostgreSQL 15 you also see it during crash recovery, because the postmaster is told as soon as redo begins.- On PostgreSQL 18, the same message with
DETAIL: Recovery snapshot is not yet ready for hot standby.: a standby is consistent but cannot build a snapshot yet. The hint tells you to close write transactions with many subtransactions on the primary. the database system is not accepting connectionswithDETAIL: Hot standby mode is disabled.: the server is in recovery andhot_standbyis off. It will not take connections until recovery ends. The default is on.the database system is in recovery mode: a backend crashed, the postmaster killed all other sessions, and it is reinitializing before redo starts.the database system is shutting down: a shutdown is in progress.
Step 1: read the server log, not the client error
The client message tells you only that you have to wait. The server log tells you why and for how long. A normal crash recovery looks like this:
LOG: database system was interrupted; last known up at 2026-11-24 07:58:12 UTC
LOG: database system was not properly shut down; automatic recovery in progress
LOG: redo starts at 3A/7C0012F8
LOG: redo in progress, elapsed time: 10.01 s, current LSN: 3A/9F2210C0
LOG: redo in progress, elapsed time: 20.01 s, current LSN: 3A/C4A81D48
LOG: redo done at 3B/10F3E2A0 system usage: ...
LOG: database system is ready to accept connections
The redo in progress lines appear on PostgreSQL 15 and later. They come from log_startup_progress_interval, which defaults to 10 seconds (release notes). Compare current LSN between two lines to get the replay speed, and compare it with the end of WAL to estimate the time left. On older versions you only get redo starts and, at the end, redo done.
If you see in recovery mode, scroll up to find the crash itself:
LOG: server process (PID 48211) was terminated by signal 9: Killed
LOG: terminating any other active server processes
LOG: all server processes terminated; reinitializing
A backend killed by signal 9 is very often the Linux OOM killer. See our article on terminated by signal 9: Killed. Because restart_after_crash is on by default, PostgreSQL restarts by itself, and crash recovery follows. If the cause is still there, you get a loop: crash, recovery, crash again.
Step 2: check the cluster state from outside
pg_controldata reads the control file directly and works even when no one can connect:
$ sudo -u postgres pg_controldata /var/lib/postgresql/18/main | \
grep -E 'cluster state|REDO location|Latest checkpoint location|Time of latest checkpoint'
Database cluster state: in crash recovery
Latest checkpoint location: 3A/7D44A1B0
Latest checkpoint's REDO location: 3A/7C0012F8
Time of latest checkpoint: Tue 24 Nov 2026 07:56:40 UTC
in crash recovery and in archive recovery mean replay is running. in production means the server finished recovery. For health checks, pg_isready returns exit code 1 when the server rejects connections, for example during startup, and 2 when there is no response at all:
$ pg_isready -h db1 -p 5432
db1:5432 - rejecting connections
$ echo $?
1
Exit code 1 means "alive, wait". Exit code 2 means "not running or not reachable". Your monitoring and your failover tool should treat them differently.
Do not restart a server that is in recovery. Each restart throws away the replay progress since the last checkpoint or restartpoint, and the next start replays that WAL again. In our experience, the most common way a 10-minute recovery becomes an hour is someone, or some automation, restarting the service every few minutes because it "is not responding".
Step 3: if it does not progress
- The LSN is moving but slowly. Replay is limited by storage. Watch the disk with
iostat. You can only wait, or fail over to a replica if you have one. - The log shows nothing for a long time before
redo starts. Before crash recovery, PostgreSQL syncs all files in the data directory. The default recovery_init_sync_method isfsync, which opens every file. With hundreds of thousands of files this takes a long time. On Linux,syncfs(available since PostgreSQL 14) syncs whole file systems instead. - A standby says "consistent recovery state has not been yet reached" for a long time. It needs more WAL. Check that
primary_conninfoorrestore_commandworks and that the required WAL still exists on the primary or in the archive. - The server crashes again during recovery. Look for the reason in the log: no disk space for WAL, corrupt files, or the same memory problem. Fix that first. Restarting it again will not help.
What changes on large databases
On a small test instance, crash recovery takes seconds and nobody notices this message. On a busy multi-terabyte server, it can take a long time, and the same settings that make normal operation fast make recovery slow:
- Recovery time follows the WAL written since the last checkpoint. The WAL documentation explains that recovery starts at the redo point of the latest checkpoint, and that more frequent checkpoints mean faster recovery. The defaults are
checkpoint_timeout = 5minandmax_wal_size = 1GB(WAL settings). Large systems often raise both to stop the warnings described in our article on checkpoints occurring too frequently. That is correct, but it also raises the worst-case recovery time. Decide on a recovery time objective and size checkpoints for it. - WAL is replayed by a single startup process. In our experience, a primary that writes WAL with many parallel sessions can produce WAL faster than a single startup process can replay it after a crash. Test it: crash a staging copy under production-like load and time the recovery.
- Prefetching helps on slow storage. From PostgreSQL 15, recovery_prefetch (default
try) prefetches blocks referenced in WAL during replay, and the checkpointer and background writer run during crash recovery (release notes). - Health checks can make it worse. In our experience, container liveness probes and service monitors that restart PostgreSQL after a timeout are the main reason recoveries never finish. A probe should treat "rejecting connections" as alive.
- Decide in advance: wait or fail over. With a healthy replica, failing over is usually faster than waiting for a long crash recovery. The documentation notes that clusterware may turn
restart_after_crashoff so that it can take control. Write down which one your cluster does and test it. - Applications need backoff. When the server comes back, every client reconnects at once. Use connection retry with backoff and a pooler, and make sure the app reports 57P03 as "database starting", not as a generic outage.
Key takeaways
- "Starting up", "not yet accepting connections" and "in recovery mode" all mean PostgreSQL is alive but replaying WAL or reinitializing. The exact text depends on the version.
- Read the server log:
redo starts,redo in progress(PostgreSQL 15+) andredo doneshow progress. - Find the original crash first, often an OOM kill, or the server will crash again.
- Do not restart a server in recovery. Treat
pg_isreadyexit code 1 as "wait". - Recovery time grows with checkpoint distance. Size
max_wal_sizeandcheckpoint_timeoutfor your recovery target, and test it under load.