FATAL: the database system is starting up

PostgreSQL is still starting (or recovering) and not accepting connections yet.

Seen on: PostgreSQL

Meaning

After a restart or crash, PostgreSQL replays WAL before accepting connections. Apps that start at the same time (Docker Compose) connect too early.

Common causes

  • App starting before the database is ready
  • Crash recovery replaying WAL
  • Replica not yet consistent

⚑ Quick fix

  1. Add retries/backoff on startup
  2. Use Compose healthchecks with depends_on: condition: service_healthy
  3. Check logs if it stays in this state

Detailed fix by platform

Docker

  1. healthcheck: { test: ["CMD-SHELL", "pg_isready -U postgres"], interval: 5s, retries: 10 }

How to diagnose

  1. Duration β€” Seconds or stuck?
  2. Logs β€” Recovery progress?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace β€” we'll detect the platform and point to the most likely cause.