redis/redis-py · error · ConnectionError
To maximize compatibility with all Redis products, client-si
Error message
To maximize compatibility with all Redis products, client-side caching is supported by Redis 7.4 or later
What it means
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).
Source
Thrown at redis/connection.py:1727
self._conn.connect()
server_name = self._conn.handshake_metadata.get(b"server", None)
if server_name is None:
server_name = self._conn.handshake_metadata.get("server", None)
server_ver = self._conn.handshake_metadata.get(b"version", None)
if server_ver is None:
server_ver = self._conn.handshake_metadata.get("version", None)
if server_ver is None or server_name is None:
raise ConnectionError("Cannot retrieve information about server version")
server_ver = ensure_string(server_ver)
server_name = ensure_string(server_name)
if (
server_name != self.DEFAULT_SERVER_NAME
or compare_versions(server_ver, self.MIN_ALLOWED_VERSION) == 1
):
raise ConnectionError(
"To maximize compatibility with all Redis products, client-side caching is supported by Redis 7.4 or later" # noqa: E501
)
def on_connect(self):
self._conn.on_connect()
def disconnect(self, *args, **kwargs):
with self._cache_lock:
self._cache.flush()
self._conn.disconnect(*args, **kwargs)
def check_health(self):
self._conn.check_health()
def send_packed_command(self, command, check_health=True):
# TODO: Investigate if it's possible to unpack command
# or extract keys from packed command
# Pre-packed commands are not individually cacheable, so make sure theView on GitHub (pinned to da03cdc7e8)
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.
Example fix
// before r = redis.Redis(host=h, cache=cache_config) # server is 7.2 r.ping() // after r = redis.Redis(host=h) # upgrade server to 7.4, then re-enable cache
Defensive patterns
Strategy: validation
Validate before calling
import redis
info = redis.Redis(host=h, protocol=3).info()
ver = tuple(int(x) for x in info['redis_version'].split('.'))
if ver < (7, 4, 0):
raise ValueError('Client-side caching requires Redis >= 7.4.0') Try / catch
try:
r = redis.Redis(host=h, protocol=3, cache=cache_config)
r.ping()
except redis.exceptions.ConnectionError as e:
if '7.4' in str(e):
r = redis.Redis(host=h, protocol=3) # disable cache until upgrade
r.ping() Prevention
- Verify server version >= 7.4.0 before enabling client-side caching.
- Ensure the server reports server='redis' via HELLO.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot retrieve information about server version
- Cannot create cache key.
- Client caching is only supported with RESP version 3
- Cache must implement CacheInterface
- Maintenance notifications handlers on connection are only su
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/3e16bf287ce5e1c7.json.
Report an issue: GitHub.