MASTERDOWN error
A replica lost its link to its primary and is set not to serve data that may be out of date.
A replica returns this error when it has lost its connection to its primary, and its replica-serve-stale-data setting is no. With this setting, the replica refuses commands while it can't get updates from the primary. This way, it never answers with data that may be out of date.
MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'.
In client libraries
| Client library | Exception or error type | Message |
|---|---|---|
| redis-py | MasterDownError |
Link with MASTER is down and replica-serve-stale-data is set to 'no'. |
| Jedis | JedisDataException |
MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'. |
| node-redis | SimpleErrorTest with err.message.startsWith('MASTERDOWN') |
MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'. |
| Lettuce The async API wraps the exception in an ExecutionException (get()) or a CompletionException (join()). |
RedisCommandExecutionException |
MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'. |
| go-redis | redis.ErrorTest with redis.IsMasterDownError(err) |
MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'. |
| ioredis | ReplyErrorTest with err.message.startsWith('MASTERDOWN') |
MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'. |
| StackExchange.Redis NRedisStack uses StackExchange.Redis, so it raises the same exceptions. The sync and async APIs raise the same exceptions. |
RedisServerException |
MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'. |
| Predis | Predis\Response\ServerExceptionTest with $e->getErrorType() === 'MASTERDOWN' |
MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'. |
| redis-rb | Redis::ConnectionError |
MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'. (redis://<host>:<port>) |
| redis-rs The sync and async APIs raise the same errors. |
ErrorKind::Server(ServerErrorKind::MasterDown) |
MasterDown: Link with MASTER is down and replica-serve-stale-data is set to 'no'. |
How to fix it
- On the replica, run
INFO replication.master_link_status:downconfirms that the link is down.master_hostandmaster_portshow the address of the primary that the replica is trying to reach. - Check that the primary is running, and that the replica can reach it at that address.
- If the primary requires a password, check that the replica has it in its
masterauthsetting. If the primary uses access control list (ACL) users, setmasterusertoo. See Setting a replica to authenticate to a master. - Look in the replica's log for the reason that the link failed.
If your app can use data that may be out of date, set replica-serve-stale-data yes, which is the default. The replica then keeps answering commands while the link is down.