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

Source

Thrown at redis.go:567

	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
}

// loadPipelinePool returns the pipeline-pool ref, or nil when pipelines use
// the main pool (PipelinePoolSize < 0, or an internal wrapper client).
func (c *baseClient) loadPipelinePool() *pipelinePoolRef {
	return c.pipelinePool
}

// getPipelinePool returns the dedicated pipeline pool as a pool.Pooler, or a
// true nil interface when there is none. Callers must use this rather than
// wrapping loadPipelinePool().pool themselves where a pool.Pooler is expected:

View on GitHub (pinned to c5cad058c7)

When it happens

Trigger: Thrown at redis.go:567 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/85ec1bfa01e74a34. Report an issue: GitHub.