{"id":"ad03480c73014861","repo":"go-redis/redis","slug":"pubsub-connection-is-not-usable","errorCode":null,"errorMessage":"pubsub: connection is not usable","messagePattern":"pubsub: connection is not usable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pubsub.go","lineNumber":175,"sourceCode":"\nfunc (c *PubSub) releaseConnWithLock(\n\tctx context.Context,\n\tcn *pool.Conn,\n\terr error,\n\tallowTimeout bool,\n) {\n\tc.mu.Lock()\n\tc.releaseConn(ctx, cn, err, allowTimeout)\n\tc.mu.Unlock()\n}\n\nfunc (c *PubSub) releaseConn(ctx context.Context, cn *pool.Conn, err error, allowTimeout bool) {\n\tif c.cn != cn {\n\t\treturn\n\t}\n\n\tif !cn.IsUsable() || cn.ShouldHandoff() {\n\t\tc.reconnect(ctx, fmt.Errorf(\"pubsub: connection is not usable\"))\n\t\treturn\n\t}\n\n\tif isBadConn(err, allowTimeout, c.opt.Addr) {\n\t\tc.reconnect(ctx, err)\n\t}\n}\n\nfunc (c *PubSub) reconnect(ctx context.Context, reason error) {\n\tif c.cn != nil && c.cn.ShouldHandoff() {\n\t\tnewEndpoint := c.cn.GetHandoffEndpoint()\n\t\t// If new endpoint is NULL, use the original address\n\t\tif newEndpoint == internal.RedisNull {\n\t\t\tnewEndpoint = c.opt.Addr\n\t\t}\n\n\t\tif newEndpoint != \"\" {\n\t\t\t// Update the address in the options","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/pubsub.go#L157-L193","documentation":"Error \"pubsub: connection is not usable\" thrown in go-redis/redis.","triggerScenarios":"Thrown at pubsub.go:175 when the library encounters an invalid state.","commonSituations":"Monitor PubSub health with ReceiveTimeout and re-create the subscription on failure.","solutions":["Reconnect/resubscribe the PubSub; the underlying connection became unusable","Check for network errors or server-side disconnects that invalidated the conn"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}