redis/go-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 redis/go-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 options

View on GitHub (pinned to c5cad058c7)

When it happens

Trigger: Thrown at pubsub.go:175 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of redis/go-redis@c5cad058c7 (2026-09-01). Data as JSON: /api/errors/6147f21a951695e5. Report an issue: GitHub.