redis/redis-py · error · ConnectionError
To maximize compatibility with all Redis products…
Error message
To maximize compatibility with all Redis products, client-side caching is supported by Redis 7.4 or later
What it means
Raised in CacheProxyConnection.connect (connection.py:1739-1745) after the server identity is retrieved, when the server name is not 'redis' OR the version is older than MIN_ALLOWED_VERSION ('7.4.0'). Client-side caching via the cache proxy is only supported on genuine Redis >= 7.4 to maximise compatibility across products; anything else (Valkey, older Redis, or Redis < 7.4) is rejected at connect time.
Solutions
- Upgrade to Redis >= 7.4.0 if you need client-side caching.
- Disable the cache (remove cache=) on incompatible servers.
- If on Valkey/other, do not enable this client-side caching feature.
- Verify with INFO server / HELLO that server name is 'redis' and version >= 7.4.
Example fix
# before r = redis.Redis(host=h, port=p, protocol=3, cache=my_cache) # Redis 7.2 # after r = redis.Redis(host=h, port=p, protocol=3) # no cache on <7.4
Defensive patterns
Strategy: validation
Validate before calling
from redis.connection import CacheProxyConnection
MIN = CacheProxyConnection.MIN_ALLOWED_VERSION # '7.4.0'
info = redis.Redis(host=h, port=p, protocol=3).info('server')
ok = info.get('redis_version') and compare_versions(info['redis_version'], MIN) <= 0
r = redis.Redis(host=h, port=p, protocol=3, cache=my_cache) if ok else \
redis.Redis(host=h, port=p, protocol=3) # no cache on older/non-redis Type guard
def supports_csc(info: dict) -> bool:
return (
info.get('redis_version', '0.0.0') is not None
and compare_versions(info['redis_version'], '7.4.0') <= 0
) Try / catch
from redis.exceptions import ConnectionError
try:
r = redis.Redis(host=h, port=p, protocol=3, cache=my_cache)
r.ping()
except ConnectionError as e:
if 'client-side caching' in str(e):
r = redis.Redis(host=h, port=p, protocol=3) # disable cache
else:
raise Prevention
- Gate client-side caching on INFO server: name=='redis' and version>=7.4.
- Don't enable the cache on Valkey or Redis < 7.4.
- Keep a no-cache fallback config for lower environments.
When it happens
Trigger: Enabling the client-side cache against Valkey, Redis < 7.4, or any server whose HELLO 'server' field is not 'redis'. compare_versions(server_ver,'7.4.0')==1 means the detected version is strictly less than 7.4.0.
Common situations: Dev environment on an older Redis; using Valkey as a Redis replacement; assuming the cache works on any RESP3 server.
Related errors
- Cache must implement CacheInterface
- Cannot retrieve information about server version
- Client caching is only supported with RESP version 3
- Client caching is only supported with RESP version 3
- Eviction policy should be associated with valid cache.
AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10).
Data as JSON: /api/errors/3e16bf287ce5e1c7.
Report an issue: GitHub.
Appendix: source
Thrown at redis/connection.py:1743
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 6a6b581b48)