redis/redis-py · critical · MasterNotFoundError
No master found for {service_name!r}{error_info}
Error message
No master found for {service_name!r}{error_info} What it means
Raised as MasterNotFoundError from Sentinel.discover_master (redis/asyncio/sentinel.py:344) after iterating every configured Sentinel: none returned a master state for service_name that passes check_master_state (is_master True, not SDOWN/ODOWN, and enough peer sentinels). The error_info suffix lists per-sentinel connection errors if any sentinels were unreachable.
Source
Thrown at redis/asyncio/sentinel.py:344
state = masters.get(service_name)
if state and self.check_master_state(state, service_name):
# Put this sentinel at the top of the list
self.sentinels[0], self.sentinels[sentinel_no] = (
sentinel,
self.sentinels[0],
)
ip = (
self._force_master_ip
if self._force_master_ip is not None
else state["ip"]
)
return ip, state["port"]
error_info = ""
if len(collected_errors) > 0:
error_info = f" : {', '.join(collected_errors)}"
raise MasterNotFoundError(f"No master found for {service_name!r}{error_info}")
def filter_slaves(
self, slaves: Iterable[Mapping]
) -> Sequence[Tuple[EncodableT, EncodableT]]:
"""Remove slaves that are in an ODOWN or SDOWN state"""
slaves_alive = []
for slave in slaves:
if slave["is_odown"] or slave["is_sdown"]:
continue
slaves_alive.append((slave["ip"], slave["port"]))
return slaves_alive
def filter_replicas(
self, replicas: Iterable[Mapping]
) -> Sequence[Tuple[EncodableT, EncodableT]]:
"""Remove replicas that are in an ODOWN or SDOWN state.
This is an alias for :py:meth:`filter_slaves`,View on GitHub (pinned to da03cdc7e8)
Solutions
- Verify service_name matches the Sentinel-monitored master name exactly.
- Check Sentinel connectivity — the error_info suffix names which sentinels failed and why.
- Lower min_other_sentinels if quorum is over-strict, or wait out an in-progress failover and retry.
- Confirm at least one Sentinel reports the master as is_master with is_sdown/is_odown False.
Example fix
# before
master = sentinel.master_for('mymaster-typo')
await master.set('k','v') # MasterNotFoundError
# after
master = sentinel.master_for('mymaster') # correct service name Defensive patterns
Strategy: try-catch
Validate before calling
states = await sentinel.sentinel_masters()
if service_name not in states:
raise ConfigError(f'service {service_name!r} not known to sentinel') Try / catch
from redis.sentinel import MasterNotFoundError
try:
addr = await sentinel.discover_master(service_name)
except MasterNotFoundError as e:
logger.error('master discovery failed: %s', e)
raise Prevention
- Verify service_name against SENTINEL MASTERS output.
- Keep min_other_sentinels realistic; do not set it above the deployed quorum.
When it happens
Trigger: First command on a master_for(...) client, or connection reset mid-life, when no Sentinel knows a healthy master; service_name typo; all Sentinels unreachable (collected_errors populated); failover in progress with no acknowledged master yet.
Common situations: Wrong service_name; Sentinel nodes misconfigured/unreachable; failover mid-flight; min_other_sentinels set too high so otherwise-valid responses are rejected.
Related errors
- The previous master is now a slave
- No slave found for {self.service_name!r}
- The previous master is now a slave
- No slave found for {self.service_name!r}
- No master found for {service_name!r}{error_info}
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/65e382ad22dfdf73.json.
Report an issue: GitHub.