How to Fix PostgreSQL Error: Database System is in Recovery Mode

This message appears when connecting to a PostgreSQL server that is in recovery mode - either recovering from a crash or operating as a hot standby replica.

Impact

Database is read-only during recovery. Write operations are rejected. On standby servers, this is normal and expected.

Common Causes

  1. Server is hot standby replica
  2. Crash recovery in progress
  3. Point-in-time recovery (PITR)
  4. Standby promotion not complete

Troubleshooting and Resolution Steps

  1. Check if server is standby:

    SELECT pg_is_in_recovery();
    -- Returns true if in recovery
    
  2. Wait for recovery to complete:

    # Watch logs for completion
    tail -f /var/log/postgresql/postgresql-15-main.log
    
  3. Promote standby if needed:

    # Promote standby to primary
    pg_ctl promote -D /var/lib/postgresql/15/main
    

Additional Information

  • Normal state for read replicas
  • Read-only during recovery
  • Some operations restricted even with hot_standby
  • Monitor recovery progress in logs

Frequently Asked Questions

Q: Can I write to a standby server?
A: No, standby servers are read-only. Write to primary server.

Q: How long does recovery take?
A: Depends on amount of WAL to replay. Minutes to hours for large databases.

Pulse - Elasticsearch Operations Done Right

Pulse can solve your Elasticsearch issues

Subscribe to the Pulse Newsletter

Get early access to new Pulse features, insightful blogs & exclusive events , webinars, and workshops.

We use cookies to provide an optimized user experience and understand our traffic. To learn more, read our use of cookies; otherwise, please choose 'Accept Cookies' to continue using our website.