## TL;DR
After a crash or restart, Postgres replays WAL before accepting connections; "in recovery mode" during that window is normal. Wait for replay to finish, and only investigate if it stalls (disk full, corrupt WAL, or a stuck restore). Connections succeed once recovery completes.

## Error
```text
postgres: FATAL: the database system is in recovery mode
```

## Steps
1. Check the logs: look for the recovery progress messages and any errors. Expected: you see replay proceeding, or the specific stall reason.
2. Wait a reasonable window: large WAL backlogs take time proportional to their size. Expected: recovery completes and connections are accepted.
3. If it stalls, check disk space: recovery needs room for WAL and temp files. Expected: free space, or a clear disk-full cause.
4. Check for WAL corruption or a broken archive-restore command: the logs name the failing WAL segment. Expected: you know whether the WAL stream is healthy.
5. For a standby, confirm this is expected: standbys are permanently "in recovery" by design; the error just means you connected to the replica. Expected: you connect to the primary for writes.

## When to use
- Postgres refuses connections with "in recovery mode" after restarts or crashes
- Standbys rejecting writes (expected behavior)
- Investigating stuck recovery

## When not to use
- Password or role authentication failures (different FATAL)
- The database is up but slow (performance tuning)

## Tool compatibility
- Postgres WAL replay, recovery logs; primary versus standby roles

## Variant phrasings
### postgres stuck in recovery
Check disk and WAL health; healthy recovery finishes on its own.

### cannot connect standby postgres
Standbys stay in recovery by design; write to the primary.

## Why it happens
Postgres guarantees durability by replaying the write-ahead log after any unclean shutdown, and it refuses connections until the data files are consistent. The FATAL is the server protecting you from reading half-recovered data.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_HmblEpBl9Kg4jJmmDCvaKw
