{"id":"627a83637c509908","repo":"redis/redis-py","slug":"passing-a-host-requires-passing-a-port-and-vice-v","errorCode":null,"errorMessage":"Passing a host requires passing a port, and vice versa","messagePattern":"Passing a host requires passing a port, and vice versa","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/cluster.py","lineNumber":3018,"sourceCode":"        If host is passed without port, or vice versa, a DataError will be\n        thrown.\n        :type cluster: RedisCluster\n        :type node: ClusterNode\n        :type host: str\n        :type port: int\n        \"\"\"\n        if node is not None:\n            # node is passed by the user\n            self._raise_on_invalid_node(cluster, node, node.host, node.port)\n            pubsub_node = node\n        elif host is not None and port is not None:\n            # host and port passed by the user\n            node = cluster.get_node(host=host, port=port)\n            self._raise_on_invalid_node(cluster, node, host, port)\n            pubsub_node = node\n        elif any([host, port]) is True:\n            # only 'host' or 'port' passed\n            raise DataError(\"Passing a host requires passing a port, and vice versa\")\n        else:\n            # nothing passed by the user. set node to None\n            pubsub_node = None\n\n        self.node = pubsub_node\n\n    def get_pubsub_node(self):\n        \"\"\"\n        Get the node that is being used as the pubsub connection\n        \"\"\"\n        return self.node\n\n    def _raise_on_invalid_node(self, redis_cluster, node, host, port):\n        \"\"\"\n        Raise a RedisClusterException if the node is None or doesn't exist in\n        the cluster.\n        \"\"\"\n        if node is None or redis_cluster.get_node(node_name=node.name) is None:","sourceCodeStart":3000,"sourceCodeEnd":3036,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/cluster.py#L3000-L3036","documentation":"Error \"Passing a host requires passing a port, and vice versa\" thrown in redis/redis-py.","triggerScenarios":"Thrown at redis/cluster.py:3018 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}