{"id":"6847122c21b926a3","repo":"redis/redis-py","slug":"rediscluster-requires-at-least-one-node-to-discove-684712","errorCode":null,"errorMessage":"RedisCluster requires at least one node to discover the cluster. Please provide one of the followings:\n1. host and port, for example:\n RedisCluster(host='localhost', port=6379)\n2. list of startup nodes, for example:\n RedisCluster(startup_nodes=[ClusterNode('localhost', 6379), ClusterNode('localhost', 6378)])","messagePattern":"RedisCluster requires at least one node to discover the cluster\\. Please provide one of the followings:\n1\\. host and port, for example:\n RedisCluster\\(host='localhost', port=6379\\)\n2\\. list of startup nodes, for example:\n RedisCluster\\(startup_nodes=\\[ClusterNode\\('localhost', 6379\\), ClusterNode\\('localhost', 6378\\)\\]\\)","errorType":"exception","errorClass":"RedisClusterException","httpStatus":null,"severity":"error","filePath":"redis/cluster.py","lineNumber":853,"sourceCode":"            if \"path\" in url_options:\n                raise RedisClusterException(\n                    \"RedisCluster does not currently support Unix Domain \"\n                    \"Socket connections\"\n                )\n            if \"db\" in url_options and url_options[\"db\"] != 0:\n                # Argument 'db' is not possible to use in cluster mode\n                raise RedisClusterException(\n                    \"A ``db`` querystring option can only be 0 in cluster mode\"\n                )\n            kwargs.update(url_options)\n            host = kwargs.get(\"host\")\n            port = kwargs.get(\"port\", port)\n            startup_nodes.append(ClusterNode(host, port))\n        elif host is not None and port is not None:\n            startup_nodes.append(ClusterNode(host, port))\n        elif len(startup_nodes) == 0:\n            # No startup node was provided\n            raise RedisClusterException(\n                \"RedisCluster requires at least one node to discover the \"\n                \"cluster. Please provide one of the followings:\\n\"\n                \"1. host and port, for example:\\n\"\n                \" RedisCluster(host='localhost', port=6379)\\n\"\n                \"2. list of startup nodes, for example:\\n\"\n                \" RedisCluster(startup_nodes=[ClusterNode('localhost', 6379),\"\n                \" ClusterNode('localhost', 6378)])\"\n            )\n        # Update the connection arguments\n        # Whenever a new connection is established, RedisCluster's on_connect\n        # method should be run\n        # If the user passed on_connect function we'll save it and run it\n        # inside the RedisCluster.on_connect() function\n        self.user_on_connect_func = kwargs.pop(\"redis_connect_func\", None)\n        kwargs.update({\"redis_connect_func\": self.on_connect})\n        kwargs = cleanup_kwargs(**kwargs)\n        if retry:\n            self.retry = retry","sourceCodeStart":835,"sourceCodeEnd":871,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/cluster.py#L835-L871","documentation":"Raised in `RedisCluster.__init__` when no bootstrap node can be determined. The cluster client needs at least one reachable node to perform slot/topology discovery; if neither `url`, nor `host`+`port`, nor a non-empty `startup_nodes` list is supplied, it cannot begin discovery and raises RedisClusterException listing the supported construction forms.","triggerScenarios":"Calling `RedisCluster()` with no arguments; passing `startup_nodes=[]` (the default) without host/port; providing only host without port or vice-versa; supplying a malformed URL that parses to neither host nor startup_nodes.","commonSituations":"Missing/typo'd configuration; environment variables for host/port not loaded; constructing from a config dict where both host and startup_nodes ended up None.","solutions":["Provide host and port: `RedisCluster(host='localhost', port=7000)`.","Or supply startup_nodes: `RedisCluster(startup_nodes=[ClusterNode('h', 7000), ClusterNode('h', 7001)])`.","Or use `RedisCluster.from_url('redis://host:7000')`.","Verify env vars/config loading actually populates the values before constructing."],"exampleFix":"# before\nrc = RedisCluster()  # raises: requires at least one node\n\n# after\nrc = RedisCluster(host='localhost', port=7000)","handlingStrategy":"validation","validationCode":"def make_cluster(host=None, port=None, startup_nodes=None, url=None):\n    if not (url or (host and port) or startup_nodes):\n        raise ValueError('Provide host+port, startup_nodes, or url')\n    return RedisCluster(host=host, port=port, startup_nodes=startup_nodes, url=url)","typeGuard":"def has_bootstrap_node(host, port, startup_nodes, url) -> bool:\n    return bool(url) or bool(host and port) or bool(startup_nodes)","tryCatchPattern":null,"preventionTips":["Always supply host+port, startup_nodes, or url.","Validate that env vars / config loading populated these before constructing."],"tags":["cluster","config","initialization","discovery"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}