psql -d appdb -c "SELECT pg_is_in_recovery();"

Category: Databases & SQL

psql -d appdb -c "SELECT pg_is_in_recovery();"

Check if this server is a standby

Returns true on a standby replaying WAL and false on a primary that accepts writes. The quickest way to confirm a node's role before promoting or failing over.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.