{"id":"d96f7f50d3585143","repo":"go-redis/redis","slug":"redis-connection-is-not-usable","errorCode":null,"errorMessage":"redis: connection is not usable","messagePattern":"redis: connection is not usable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"redis.go","lineNumber":553,"sourceCode":"\tif err := c.initConn(ctx, cn); err != nil {\n\t\tp.Remove(ctx, cn, err)\n\t\tif unwrapped := errors.Unwrap(err); unwrapped != nil {\n\t\t\treturn unwrapped\n\t\t}\n\t\treturn err\n\t}\n\n\tif dialStartNs := cn.GetDialStartNs(); dialStartNs > 0 {\n\t\tif cb := pool.GetMetricConnectionCreateTimeCallback(); cb != nil {\n\t\t\tduration := time.Duration(time.Now().UnixNano() - dialStartNs)\n\t\t\tcb(ctx, duration, cn)\n\t\t}\n\t}\n\n\t// initConn will transition to IDLE state, so we need to acquire it\n\t// before returning it to the user.\n\tif !cn.TryAcquire() {\n\t\terr := fmt.Errorf(\"redis: connection is not usable\")\n\t\t// Remove rather than abandon: an unacquirable conn left outside the\n\t\t// pool's accounting would leak its slot.\n\t\tp.Remove(ctx, cn, err)\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\n// poolForConn returns the pool that owns cn — the dedicated pipeline pool when\n// cn was dialed there, otherwise the main pool. Re-auth close/accounting must\n// target the owning pool so a failed pipeline connection is removed from the\n// pipeline pool's books, not the main pool's.\nfunc (c *baseClient) poolForConn(cn *pool.Conn) pool.Pooler {\n\tif c.pipelinePool != nil && c.pipelinePoolName != \"\" && cn.PoolName() == c.pipelinePoolName {\n\t\treturn c.pipelinePool\n\t}\n\treturn c.connPool","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/redis.go#L535-L571","documentation":"Error \"redis: connection is not usable\" thrown in go-redis/redis.","triggerScenarios":"Thrown at redis.go:553 when the library encounters an invalid state.","commonSituations":"Rely on the client's automatic retry instead of holding connections across operations.","solutions":["Retry the operation; the pool will supply a usable connection","Check ReadTimeout/PoolTimeout settings if connections die mid-use"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}