{"record":{"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":"error","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/6a6b581b48225afa0b76912d1028c6035baee932/redis/asyncio/sentinel.py#L326-L362","documentation":"Raised as MasterNotFoundError (a ConnectionError subclass) from Sentinel.discover_master after iterating every configured Sentinel node and finding none that can report a valid, non-ODOWN master for the given service_name. The message appends collected connection errors from each sentinel it could not reach. This is the top-level master-discovery failure for the Sentinel client.","triggerScenarios":"Calling discover_master(service_name) (directly or via master_for() usage) where every sentinel either is unreachable (ConnectionError/TimeoutError, recorded in error_info) or does not return a passing master state via check_master_state.","commonSituations":"All Sentinel nodes are down or unreachable. The service_name does not exist in Sentinel config. Master is in ODOWN (objective down) so check_master_state rejects it. Network partition between the client and the Sentinel quorum. Wrong sentinel addresses/ports in the Sentinel() constructor.","solutions":["Confirm the Sentinel addresses passed to Sentinel(...) are correct and reachable (telnet/redis-cli ping each one).","Run `redis-cli -p 26379 sentinel get-master-addr-by-name <service_name>` to confirm Sentinel knows the master.","Check that the master is not flagged ODOWN/SDOWN and that Sentinel quorum is healthy.","Verify the service_name matches the monitored master name in sentinel.conf."],"exampleFix":"# before\nsentinel = Sentinel([('sentinel-host', 26379)])\nmaster = sentinel.master_for('wrong-name')  # MasterNotFoundError\n# after\nsentinel = Sentinel([('sentinel-host', 26379)])\nmaster = sentinel.master_for('mymaster')  # correct monitored name","handlingStrategy":"retry","validationCode":"addrs = await sentinel.discover_master(service_name)  # raises MasterNotFoundError if down","typeGuard":null,"tryCatchPattern":"from redis.asyncio.sentinel import MasterNotFoundError\nfor attempt in range(retries):\n    try:\n        return await sentinel.master_for(service_name).get(key)\n    except MasterNotFoundError:\n        await asyncio.sleep(backoff)","preventionTips":["Use multiple sentinel nodes in the Sentinel(...) list for redundancy.","Validate service_name and sentinel reachability at startup."],"tags":["sentinel","master","discovery","async","network"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}