{"id":"65e382ad22dfdf73","repo":"redis/redis-py","slug":"no-master-found-for-service-name-r-error-info","errorCode":null,"errorMessage":"No master found for {service_name!r}{error_info}","messagePattern":"No master found for (.+?)(.+?)","errorType":"exception","errorClass":"MasterNotFoundError","httpStatus":null,"severity":"critical","filePath":"redis/asyncio/sentinel.py","lineNumber":344,"sourceCode":"            state = masters.get(service_name)\n            if state and self.check_master_state(state, service_name):\n                # Put this sentinel at the top of the list\n                self.sentinels[0], self.sentinels[sentinel_no] = (\n                    sentinel,\n                    self.sentinels[0],\n                )\n\n                ip = (\n                    self._force_master_ip\n                    if self._force_master_ip is not None\n                    else state[\"ip\"]\n                )\n                return ip, state[\"port\"]\n\n        error_info = \"\"\n        if len(collected_errors) > 0:\n            error_info = f\" : {', '.join(collected_errors)}\"\n        raise MasterNotFoundError(f\"No master found for {service_name!r}{error_info}\")\n\n    def filter_slaves(\n        self, slaves: Iterable[Mapping]\n    ) -> Sequence[Tuple[EncodableT, EncodableT]]:\n        \"\"\"Remove slaves that are in an ODOWN or SDOWN state\"\"\"\n        slaves_alive = []\n        for slave in slaves:\n            if slave[\"is_odown\"] or slave[\"is_sdown\"]:\n                continue\n            slaves_alive.append((slave[\"ip\"], slave[\"port\"]))\n        return slaves_alive\n\n    def filter_replicas(\n        self, replicas: Iterable[Mapping]\n    ) -> Sequence[Tuple[EncodableT, EncodableT]]:\n        \"\"\"Remove replicas that are in an ODOWN or SDOWN state.\n\n        This is an alias for :py:meth:`filter_slaves`,","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/asyncio/sentinel.py#L326-L362","documentation":"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.","triggerScenarios":"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.","commonSituations":"Wrong service_name; Sentinel nodes misconfigured/unreachable; failover mid-flight; min_other_sentinels set too high so otherwise-valid responses are rejected.","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."],"exampleFix":"# before\nmaster = sentinel.master_for('mymaster-typo')\nawait master.set('k','v')  # MasterNotFoundError\n# after\nmaster = sentinel.master_for('mymaster')  # correct service name","handlingStrategy":"try-catch","validationCode":"states = await sentinel.sentinel_masters()\nif service_name not in states:\n    raise ConfigError(f'service {service_name!r} not known to sentinel')","typeGuard":null,"tryCatchPattern":"from redis.sentinel import MasterNotFoundError\ntry:\n    addr = await sentinel.discover_master(service_name)\nexcept MasterNotFoundError as e:\n    logger.error('master discovery failed: %s', e)\n    raise","preventionTips":["Verify service_name against SENTINEL MASTERS output.","Keep min_other_sentinels realistic; do not set it above the deployed quorum."],"tags":["sentinel","failover","config"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}