{"record":{"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":1734,"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":1716,"sourceCodeEnd":1752,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/connection.py#L1716-L1752","documentation":"Raised in CacheProxyConnection.connect (connection.py:1727-1734) when the underlying connection's handshake_metadata lacks a 'server' or 'version' field. Client-side caching (CacheProxyConnection) needs to know the server software and version to decide compatibility, and that metadata comes from the RESP3 HELLO response. Without HELLO (e.g. protocol=2, or a server/proxy that doesn't populate handshake metadata) the version cannot be determined and the cache proxy refuses to connect.","triggerScenarios":"Enabling client-side caching (cache=...) while using protocol=2, or against a server/intermediary that does not return server & version in HELLO. handshake_metadata is only populated by the HELLO handshake (RESP3).","commonSituations":"Turning on the client-side cache without switching to RESP3; proxy in front that strips HELLO metadata; OSS Redis older than the version reporting fields.","solutions":["Use protocol=3 (RESP3) so HELLO populates handshake_metadata with server/version.","Ensure no proxy strips the HELLO response fields.","Upgrade Redis to a version that reports server name and version in HELLO.","Disable client-side caching if you cannot use RESP3."],"exampleFix":"# before\nr = redis.Redis(host=h, port=p, protocol=2, cache=my_cache)\n# after\nr = redis.Redis(host=h, port=p, protocol=3, cache=my_cache)","handlingStrategy":"validation","validationCode":"# Client-side caching requires RESP3 (HELLO) to populate handshake metadata\nassert int(protocol or 3) == 3, 'client-side caching needs protocol=3'\nr = redis.Redis(host=h, port=p, protocol=3, cache=my_cache)\n# verify metadata is populated:\nwith r.connection_pool.get_connection('HELLO') as c:\n    assert c.handshake_metadata.get(b'version') or c.handshake_metadata.get('version')","typeGuard":"null","tryCatchPattern":"from redis.exceptions import ConnectionError\ntry:\n    r = redis.Redis(host=h, port=p, protocol=3, cache=my_cache)\n    r.ping()\nexcept ConnectionError as e:\n    if 'Cannot retrieve information about server version' in str(e):\n        # strip the cache; keep the client working\n        r = redis.Redis(host=h, port=p, protocol=3)\n    else:\n        raise","preventionTips":["Always pair client-side caching with protocol=3.","Remove any proxy that strips HELLO response fields.","Smoke-test HELLO output: redis-cli -3 HELLO should show server+version."],"tags":["client-side-caching","resp3","hello","configuration"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}