go-redis/redis · error

redis: connection is not usable

Error message

redis: connection is not usable

What it means

Error "redis: connection is not usable" thrown in go-redis/redis.

Source

Thrown at redis.go:553

	if err := c.initConn(ctx, cn); err != nil {
		p.Remove(ctx, cn, err)
		if unwrapped := errors.Unwrap(err); unwrapped != nil {
			return unwrapped
		}
		return err
	}

	if dialStartNs := cn.GetDialStartNs(); dialStartNs > 0 {
		if cb := pool.GetMetricConnectionCreateTimeCallback(); cb != nil {
			duration := time.Duration(time.Now().UnixNano() - dialStartNs)
			cb(ctx, duration, cn)
		}
	}

	// initConn will transition to IDLE state, so we need to acquire it
	// before returning it to the user.
	if !cn.TryAcquire() {
		err := fmt.Errorf("redis: connection is not usable")
		// Remove rather than abandon: an unacquirable conn left outside the
		// pool's accounting would leak its slot.
		p.Remove(ctx, cn, err)
		return err
	}

	return nil
}

// poolForConn returns the pool that owns cn — the dedicated pipeline pool when
// cn was dialed there, otherwise the main pool. Re-auth close/accounting must
// target the owning pool so a failed pipeline connection is removed from the
// pipeline pool's books, not the main pool's.
func (c *baseClient) poolForConn(cn *pool.Conn) pool.Pooler {
	if c.pipelinePool != nil && c.pipelinePoolName != "" && cn.PoolName() == c.pipelinePoolName {
		return c.pipelinePool
	}
	return c.connPool

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Retry the operation; the pool will supply a usable connection
  2. Check ReadTimeout/PoolTimeout settings if connections die mid-use

When it happens

Trigger: Thrown at redis.go:553 when the library encounters an invalid state.

Common situations: Rely on the client's automatic retry instead of holding connections across operations.


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/d96f7f50d3585143.json. Report an issue: GitHub.