{"id":"3e16bf287ce5e1c7","repo":"redis/redis-py","slug":"to-maximize-compatibility-with-all-redis-products","errorCode":null,"errorMessage":"To maximize compatibility with all Redis products, client-side caching is supported by Redis 7.4 or later","messagePattern":"To maximize compatibility with all Redis products, client-side caching is supported by Redis 7\\.4 or later","errorType":"exception","errorClass":"ConnectionError","httpStatus":null,"severity":"error","filePath":"redis/connection.py","lineNumber":1727,"sourceCode":"        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()\n        self._conn.disconnect(*args, **kwargs)\n\n    def check_health(self):\n        self._conn.check_health()\n\n    def send_packed_command(self, command, check_health=True):\n        # TODO: Investigate if it's possible to unpack command\n        #  or extract keys from packed command\n        # Pre-packed commands are not individually cacheable, so make sure the","sourceCodeStart":1709,"sourceCodeEnd":1745,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/connection.py#L1709-L1745","documentation":"Raised as a ConnectionError in CacheProxyConnection.connect when the server is not 'redis' or its version is older than 7.4.0. Client-side caching (tracking) is only supported on Redis >= 7.4 for compatibility across Redis products, so the connection is refused. The version comparison uses compare_versions against MIN_ALLOWED_VERSION (7.4.0).","triggerScenarios":"Enabling client-side caching (cache config) against a Redis server older than 7.4.0, or against a non-'redis' server (e.g. Valkey/keydb reported under a different server name) that fails the DEFAULT_SERVER_NAME check. Fires at connect() after reading HELLO metadata.","commonSituations":"Pointing a CSC-enabled client at Redis 7.2 or earlier; using a compatible-but-renamed server; expecting CSC to work on an older self-hosted Redis.","solutions":["Upgrade the Redis server to 7.4.0 or later before enabling client-side caching.","Disable the cache config if you cannot upgrade the server.","Confirm the server reports server='redis' and a >= 7.4 version via HELLO."],"exampleFix":"// before\nr = redis.Redis(host=h, cache=cache_config)  # server is 7.2\nr.ping()\n// after\nr = redis.Redis(host=h)  # upgrade server to 7.4, then re-enable cache","handlingStrategy":"validation","validationCode":"import redis\ninfo = redis.Redis(host=h, protocol=3).info()\nver = tuple(int(x) for x in info['redis_version'].split('.'))\nif ver < (7, 4, 0):\n    raise ValueError('Client-side caching requires Redis >= 7.4.0')","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 '7.4' in str(e):\n        r = redis.Redis(host=h, protocol=3)  # disable cache until upgrade\n        r.ping()","preventionTips":["Verify server version >= 7.4.0 before enabling client-side caching.","Ensure the server reports server='redis' via HELLO."],"tags":["client-side-caching","server-version","configuration"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}