{"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/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/asyncio/connection.py#L958-L994","documentation":"Raised as ConnectionError during the HELLO/AUTH handshake when the client requests a specific RESP protocol via HELLO but the server's reply reports a different proto version (response.get(b'proto')/('proto') != int(self.protocol)). The server did not agree to the requested RESP version, so the connection is unusable in the negotiated shape.","triggerScenarios":"Connecting with protocol=3 to a Redis server that only supports RESP2 (e.g. Redis < 6.0), or with protocol=2 when the server forces a different version; an upstream/proxy that rewrites the HELLO reply.","commonSituations":"Local dev against an old Redis; a proxy (Twemproxy, Envoy, a cloud proxy) that strips HELLO; mismatched client/server major versions.","solutions":["Upgrade the Redis server to a version that supports the requested RESP protocol (>=6.0 for RESP3).","Match the client protocol to what the server supports (protocol=2 for older servers).","Remove any proxy between client and server that mangles HELLO responses."],"exampleFix":"// before\nclient = Redis(url='redis://old-redis:6379', protocol=3)  # raises [98]\n// after\nclient = Redis(url='redis://old-redis:6379', protocol=2)","handlingStrategy":"validation","validationCode":"# Check server version/HELLO support before forcing protocol\ninfo = await client.info('server')\nif protocol == 3 and tuple(map(int, info['redis_version'].split('.'))) < (6, 0, 0):\n    raise ValueError('Server too old for RESP3')","typeGuard":null,"tryCatchPattern":"from redis.exceptions import ConnectionError\ntry:\n    client = Redis(url=url, protocol=3)\n    await client.ping()\nexcept ConnectionError as e:\n    if 'Invalid RESP version' in str(e):\n        client = Redis(url=url, protocol=2)","preventionTips":["Match the client RESP version to the server's capabilities.","Don't put proxies between client and server that rewrite HELLO."],"tags":["connection","protocol","handshake","hello","server-version"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}