{"record":{"id":"cee30ccf6fb838bf","repo":"thanos-io/thanos","slug":"redis-unexpected-ping-response-q","errorCode":null,"errorMessage":"redis: Unexpected PING response %q","messagePattern":"redis: Unexpected PING response %q","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cortex/chunk/cache/redis_client.go","lineNumber":101,"sourceCode":"\t\ttimeout:    cfg.Timeout,\n\t\trdb:        client,\n\t}, nil\n}\n\nfunc (c *RedisClient) Ping(ctx context.Context) error {\n\tvar cancel context.CancelFunc\n\tif c.timeout > 0 {\n\t\tctx, cancel = context.WithTimeout(ctx, c.timeout)\n\t\tdefer cancel()\n\t}\n\n\tresp := c.rdb.Do(ctx, c.rdb.B().Ping().Build())\n\tpingResp, err := resp.ToString()\n\tif err != nil {\n\t\treturn errors.New(\"converting PING response to string\")\n\t}\n\tif pingResp != \"PONG\" {\n\t\treturn errors.Errorf(\"redis: Unexpected PING response %q\", pingResp)\n\t}\n\treturn nil\n}\n\nfunc (c *RedisClient) MSet(ctx context.Context, keys []string, values [][]byte) error {\n\tvar cancel context.CancelFunc\n\tif c.timeout > 0 {\n\t\tctx, cancel = context.WithTimeout(ctx, c.timeout)\n\t\tdefer cancel()\n\t}\n\n\tif len(keys) != len(values) {\n\t\treturn errors.Errorf(\"MSet the length of keys and values not equal, len(keys)=%d, len(values)=%d\", len(keys), len(values))\n\t}\n\n\tcmds := make(rueidis.Commands, 0, len(keys))\n\tfor i := range keys {\n\t\tcmds = append(cmds, c.rdb.B().Set().Key(keys[i]).Value(rueidis.BinaryString(values[i])).Ex(c.expiration).Build())","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/internal/cortex/chunk/cache/redis_client.go#L83-L119","documentation":"RedisClient.Ping converts the PING reply and expects the literal string \"PONG\". Any other string reply produces this formatted error including the unexpected response, indicating the peer is not behaving like a healthy Redis instance.","triggerScenarios":"Calling Ping() and receiving a non-PONG string, e.g. a proxy/intermediary answering PING itself, or a resp-protocol variant whose reply text differs.","commonSituations":"Pointing the endpoint at an HTTP proxy or a different TCP service that echoes something else; connecting through a load balancer with a custom PING handler; misconfigured TLS wrapper returning its own banner.","solutions":["Inspect the %q value in the error to see what actually replied.","Verify the endpoint reaches a real Redis server: run redis-cli PING manually.","Remove or reconfigure any intermediary that intercepts PING.","Confirm TLS/port settings match the server's protocol."],"exampleFix":"// before\nredis:\n  endpoint: http-proxy:6379\n// after\nredis:\n  endpoint: redis:6379","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := client.Ping(ctx); err != nil {\n    if strings.Contains(err.Error(), \"Unexpected PING response\") {\n        log.Errorf(\"peer answered PING with something else — check for proxies: %v\", err)\n    }\n    return err\n}","preventionTips":["Point redis.endpoint directly at a Redis server, not an HTTP proxy or LB with custom handlers.","Smoke-test with redis-cli PING before deploy.","Match TLS/protocol expectations on both sides."],"tags":["redis","ping","protocol"],"backgroundTag":"unexpected-response-shape","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}