{"id":"402a0f2a55aa50b2","repo":"redis/redis-py","slug":"cannot-retrieve-information-about-server-version","errorCode":null,"errorMessage":"Cannot retrieve information about server version","messagePattern":"Cannot retrieve information about server version","errorType":"exception","errorClass":"ConnectionError","httpStatus":null,"severity":"error","filePath":"redis/connection.py","lineNumber":1718,"sourceCode":"        if isinstance(self._conn, MaintNotificationsAbstractConnection):\n            self._conn.set_maint_notifications_cluster_handler_for_connection(\n                oss_cluster_maint_notifications_handler\n            )\n\n    def get_protocol(self):\n        return self._conn.get_protocol()\n\n    def connect(self):\n        self._conn.connect()\n\n        server_name = self._conn.handshake_metadata.get(b\"server\", None)\n        if server_name is None:\n            server_name = self._conn.handshake_metadata.get(\"server\", None)\n        server_ver = self._conn.handshake_metadata.get(b\"version\", None)\n        if server_ver is None:\n            server_ver = self._conn.handshake_metadata.get(\"version\", None)\n        if server_ver is None or server_name is None:\n            raise ConnectionError(\"Cannot retrieve information about server version\")\n\n        server_ver = ensure_string(server_ver)\n        server_name = ensure_string(server_name)\n\n        if (\n            server_name != self.DEFAULT_SERVER_NAME\n            or compare_versions(server_ver, self.MIN_ALLOWED_VERSION) == 1\n        ):\n            raise ConnectionError(\n                \"To maximize compatibility with all Redis products, client-side caching is supported by Redis 7.4 or later\"  # noqa: E501\n            )\n\n    def on_connect(self):\n        self._conn.on_connect()\n\n    def disconnect(self, *args, **kwargs):\n        with self._cache_lock:\n            self._cache.flush()","sourceCodeStart":1700,"sourceCodeEnd":1736,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/connection.py#L1700-L1736","documentation":"Raised as a ConnectionError in CacheProxyConnection.connect when the HELLO handshake metadata lacks 'server' or 'version' fields. Client-side caching (CacheProxyConnection) relies on HELLO to identify the server type and version, so missing metadata prevents the version gate. This typically means RESP3/HELLO did not run or the server did not return version info.","triggerScenarios":"Using a client configured with client-side caching (CacheProxyConnection wrapping the underlying connection) where on_connect did not populate handshake_metadata with server/version. Happens if protocol is not 3 (so HELLO is skipped) or the server omits these fields, or the connection is not actually going through the HELLO path.","commonSituations":"Enabling client-side caching with protocol=2 (no HELLO, so no handshake metadata); connecting to a proxy/server that strips HELLO metadata; a misconfigured CacheProxyConnection used without a real HELLO exchange.","solutions":["Ensure protocol=3 so the HELLO handshake runs and populates server/version metadata.","Connect to a genuine Redis server that returns full HELLO metadata.","Avoid client-side caching against servers/proxies that omit HELLO fields."],"exampleFix":"// before\nr = redis.Redis(host=h, protocol=2, cache=cache_config)\nr.ping()\n// after\nr = redis.Redis(host=h, protocol=3, cache=cache_config)\nr.ping()","handlingStrategy":"validation","validationCode":"# ensure protocol=3 so HELLO populates handshake metadata before enabling CSC\nif protocol not in (3, '3'):\n    raise ValueError('Client-side caching requires protocol=3 to obtain HELLO metadata')","typeGuard":null,"tryCatchPattern":"try:\n    r = redis.Redis(host=h, protocol=3, cache=cache_config)\n    r.ping()\nexcept redis.exceptions.ConnectionError as e:\n    if 'server version' in str(e):\n        r = redis.Redis(host=h, protocol=3)  # disable cache\n        r.ping()","preventionTips":["Always use protocol=3 when enabling client-side caching.","Confirm the server returns full HELLO metadata (server/version) before wrapping with CacheProxyConnection."],"tags":["client-side-caching","handshake","resp3","configuration"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}