{"id":"d8741669070a3ace","repo":"redis/redis-py","slug":"rediscluster-requires-at-least-one-node-to-discove","errorCode":null,"errorMessage":"RedisCluster requires at least one node to discover the cluster.\nPlease provide one of the following or use RedisCluster.from_url:\n   - host and port: RedisCluster(host=\"localhost\", port=6379)\n   - startup_nodes: RedisCluster(startup_nodes=[ClusterNode(\"localhost\", 6379), ClusterNode(\"localhost\", 6380)])","messagePattern":"RedisCluster requires at least one node to discover the cluster\\.\nPlease provide one of the following or use RedisCluster\\.from_url:\n   - host and port: RedisCluster\\(host=\"localhost\", port=6379\\)\n   - startup_nodes: RedisCluster\\(startup_nodes=\\[ClusterNode\\(\"localhost\", 6379\\), ClusterNode\\(\"localhost\", 6380\\)\\]\\)","errorType":"exception","errorClass":"RedisClusterException","httpStatus":null,"severity":"error","filePath":"redis/asyncio/cluster.py","lineNumber":471,"sourceCode":"        protocol: int | None = None,\n        legacy_responses: bool = True,\n        address_remap: Callable[[Tuple[str, int]], Tuple[str, int]] | None = None,\n        event_dispatcher: EventDispatcher | None = None,\n        policy_resolver: AsyncPolicyResolver = AsyncStaticPolicyResolver(),\n        maint_notifications_config: MaintNotificationsConfig | None = None,\n    ) -> None:\n        if db:\n            raise RedisClusterException(\n                \"Argument 'db' must be 0 or None in cluster mode\"\n            )\n\n        if path:\n            raise RedisClusterException(\n                \"Unix domain socket is not supported in cluster mode\"\n            )\n\n        if (not host or not port) and not startup_nodes:\n            raise RedisClusterException(\n                \"RedisCluster requires at least one node to discover the cluster.\\n\"\n                \"Please provide one of the following or use RedisCluster.from_url:\\n\"\n                '   - host and port: RedisCluster(host=\"localhost\", port=6379)\\n'\n                \"   - startup_nodes: RedisCluster(startup_nodes=[\"\n                'ClusterNode(\"localhost\", 6379), ClusterNode(\"localhost\", 6380)])'\n            )\n\n        computed_driver_info = resolve_driver_info(driver_info, lib_name, lib_version)\n\n        kwargs: Dict[str, Any] = {\n            \"max_connections\": max_connections,\n            \"connection_class\": Connection,\n            # Client related kwargs\n            \"credential_provider\": credential_provider,\n            \"username\": username,\n            \"password\": password,\n            \"client_name\": client_name,\n            \"driver_info\": computed_driver_info,","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/asyncio/cluster.py#L453-L489","documentation":"Raised by RedisCluster.__init__ (redis/asyncio/cluster.py:471) when neither (host and port) nor startup_nodes is provided. The cluster client needs at least one bootstrap node to run CLUSTER SLOTS/NODES and build the slot map; with no entry point it cannot discover topology. The message lists the two accepted construction forms.","triggerScenarios":"Calling RedisCluster() with no arguments, or passing only one of host/port, or passing an empty startup_nodes list. The guard is `if (not host or not port) and not startup_nodes:`.","commonSituations":"Loading cluster config from environment where HOST/PORT env vars are unset; misconfigured URL parsing; constructing from a dict that omitted the node specifier.","solutions":["Provide host and port: RedisCluster(host='localhost', port=16379).","Provide startup_nodes: RedisCluster(startup_nodes=[ClusterNode('h1', 6379), ClusterNode('h2', 6379)]).","Use RedisCluster.from_url('redis://host:16379/0') to parse the endpoint from a URL.","Validate that host AND port are both set (truthiness), not just one."],"exampleFix":"// before\nc = RedisCluster()  # raises\n// after\nc = RedisCluster(host='localhost', port=16379)\n# or\nc = RedisCluster.from_url('redis://localhost:16379/0')","handlingStrategy":"validation","validationCode":"if not ((host and port) or startup_nodes):\n    raise ValueError('Provide host+port or startup_nodes (or use from_url)')\nc = RedisCluster(host=host, port=port, startup_nodes=startup_nodes)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate that both host AND port are truthy before constructing.","Prefer RedisCluster.from_url(url) for config-driven setups.","Fail fast in config loading if no endpoint is configured."],"tags":["redis","asyncio","cluster","configuration","bootstrap"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}