Problem
redis-py 8.0 changed DEFAULT_RESP_VERSION from 2 to 3 (PR #4031). When connecting to a Redis server < 6.0 or a proxy that doesn't support the HELLO command, the connection fails immediately with ResponseError: unknown command — there is no automatic fallback to RESP2.
Root Cause
on_connect_check_health() in connection.py:1111-1114:
self.send_command("HELLO", self.protocol, "AUTH", *auth_args, check_health=False)
self.handshake_metadata = self.read_response() # no try-except, raises directly
Unlike Lettuce, Jedis, and go-redis which catch HELLO failures and fall back to legacy AUTH, redis-py raises the error and the connection is never established.
Impact
Users upgrading from 7.x to 8.0 with zero code changes will experience immediate connection failures if their server/proxy doesn't support HELLO. This includes:
- Redis < 6.0
- Certain managed Redis proxies
- Third-party Redis-compatible services that haven't implemented HELLO
Suggested Fix
Catch ResponseError from the HELLO command and fall back to RESP2 + standalone AUTH, similar to what other clients do:
try:
self.send_command("HELLO", self.protocol, "AUTH", *auth_args, check_health=False)
self.handshake_metadata = self.read_response()
except ResponseError:
# Server doesn't support HELLO, fall back to RESP2 AUTH
if isinstance(self._parser, _RESP3Parser):
self.set_parser(_RESP2Parser)
self._parser.on_connect(self)
self.protocol = 2
self.send_command("AUTH", *auth_args, check_health=False)
auth_response = self.read_response()
if str_if_bytes(auth_response) != "OK":
raise AuthenticationError("Invalid Username or Password")
Workaround
redis.Redis(host=host, port=port, password=password, protocol=2)
Explicitly setting protocol=2 avoids the HELLO path entirely.
Problem
redis-py 8.0 changed
DEFAULT_RESP_VERSIONfrom 2 to 3 (PR #4031). When connecting to a Redis server < 6.0 or a proxy that doesn't support theHELLOcommand, the connection fails immediately withResponseError: unknown command— there is no automatic fallback to RESP2.Root Cause
on_connect_check_health()inconnection.py:1111-1114:Unlike Lettuce, Jedis, and go-redis which catch
HELLOfailures and fall back to legacyAUTH, redis-py raises the error and the connection is never established.Impact
Users upgrading from 7.x to 8.0 with zero code changes will experience immediate connection failures if their server/proxy doesn't support
HELLO. This includes:Suggested Fix
Catch
ResponseErrorfrom theHELLOcommand and fall back to RESP2 + standaloneAUTH, similar to what other clients do:Workaround
Explicitly setting
protocol=2avoids theHELLOpath entirely.