go-redis/redis · error
pubsub: connection is not usable
Error message
pubsub: connection is not usable
What it means
Error "pubsub: connection is not usable" thrown in go-redis/redis.
Source
Thrown at pubsub.go:175
func (c *PubSub) releaseConnWithLock(
ctx context.Context,
cn *pool.Conn,
err error,
allowTimeout bool,
) {
c.mu.Lock()
c.releaseConn(ctx, cn, err, allowTimeout)
c.mu.Unlock()
}
func (c *PubSub) releaseConn(ctx context.Context, cn *pool.Conn, err error, allowTimeout bool) {
if c.cn != cn {
return
}
if !cn.IsUsable() || cn.ShouldHandoff() {
c.reconnect(ctx, fmt.Errorf("pubsub: connection is not usable"))
return
}
if isBadConn(err, allowTimeout, c.opt.Addr) {
c.reconnect(ctx, err)
}
}
func (c *PubSub) reconnect(ctx context.Context, reason error) {
if c.cn != nil && c.cn.ShouldHandoff() {
newEndpoint := c.cn.GetHandoffEndpoint()
// If new endpoint is NULL, use the original address
if newEndpoint == internal.RedisNull {
newEndpoint = c.opt.Addr
}
if newEndpoint != "" {
// Update the address in the optionsView on GitHub (pinned to 36d97525cd)
Solutions
- Reconnect/resubscribe the PubSub; the underlying connection became unusable
- Check for network errors or server-side disconnects that invalidated the conn
When it happens
Trigger: Thrown at pubsub.go:175 when the library encounters an invalid state.
Common situations: Monitor PubSub health with ReceiveTimeout and re-create the subscription on failure.
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/ad03480c73014861.json.
Report an issue: GitHub.