{"record":{"id":"0556c6fe56a135eb","repo":"redis/redis-py","slug":"invalid-resp-version","errorCode":null,"errorMessage":"Invalid RESP version","messagePattern":"Invalid RESP version","errorType":"exception","errorClass":"ConnectionError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/connection.py","lineNumber":976,"sourceCode":"            # we need to send them via HELLO\n        if auth_args and check_protocol_version(self.protocol, 3):\n            if isinstance(self._parser, _AsyncRESP2Parser):\n                self.set_parser(_AsyncRESP3Parser)\n                # update cluster exception classes\n                self._parser.EXCEPTION_CLASSES = parser.EXCEPTION_CLASSES\n                self._parser.on_connect(self)\n            if len(auth_args) == 1:\n                auth_args = [\"default\", auth_args[0]]\n            # avoid checking health here -- PING will fail if we try\n            # to check the health prior to the AUTH\n            await self.send_command(\n                \"HELLO\", self.protocol, \"AUTH\", *auth_args, check_health=False\n            )\n            response = await self.read_response()\n            if response.get(b\"proto\") != int(self.protocol) and response.get(\n                \"proto\"\n            ) != int(self.protocol):\n                raise ConnectionError(\"Invalid RESP version\")\n        # avoid checking health here -- PING will fail if we try\n        # to check the health prior to the AUTH\n        elif auth_args:\n            await self.send_command(\"AUTH\", *auth_args, check_health=False)\n\n            try:\n                auth_response = await self.read_response()\n            except AuthenticationWrongNumberOfArgsError:\n                # a username and password were specified but the Redis\n                # server seems to be < 6.0.0 which expects a single password\n                # arg. retry auth with just the password.\n                # https://github.com/andymccurdy/redis-py/issues/1274\n                await self.send_command(\"AUTH\", auth_args[-1], check_health=False)\n                auth_response = await self.read_response()\n\n            if str_if_bytes(auth_response) != \"OK\":\n                raise AuthenticationError(\"Invalid Username or Password\")\n","sourceCodeStart":958,"sourceCodeEnd":994,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/asyncio/connection.py#L958-L994","documentation":"ConnectionError from Connection.on_connect (redis/asyncio/connection.py:975) raised when, after sending HELLO with the requested protocol, the server's reported proto does not match what was requested. This happens when protocol=3 is requested but the server only speaks RESP2 (it ignores/downgrades the HELLO), so the proto field in the response differs. The library refuses to silently run on the wrong protocol.","triggerScenarios":"Connecting with protocol=3 to a Redis server older than 6.0 (no RESP3) or one configured to downgrade; a proxy that strips the HELLO protocol negotiation.","commonSituations":"Pointing a RESP3-default client at an older Redis; talking to a Redis-compatible proxy (Twemproxy, Envoy, some managed offerings) that does not forward HELLO correctly.","solutions":["Set protocol=2 if the server/proxy does not support RESP3","Upgrade the Redis server to >= 6.0 for RESP3 support","If behind a proxy, confirm it passes through HELLO negotiation"],"exampleFix":"// before\nRedis(protocol=3)  # against Redis < 6.0\n// after\nRedis(protocol=2)","handlingStrategy":"validation","validationCode":"# downgrade protocol if server is known to lack RESP3\nprotocol = 2 if server_version < (6, 0) else 3","typeGuard":null,"tryCatchPattern":"try:\n    client = Redis(protocol=3)\n    await client.ping()\nexcept ConnectionError as e:\n    if 'Invalid RESP version' in str(e):\n        client = Redis(protocol=2)\n        await client.ping()","preventionTips":["Set protocol=2 when targeting Redis < 6.0 or proxies that drop HELLO","Confirm proxies forward HELLO negotiation before using RESP3"],"tags":["async","connection","resp3","hello","server-version","compatibility"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}