{"id":"1d3b5c0d40fb9e0b","repo":"jackc/pgx","slug":"conn-closed","errorCode":null,"errorMessage":"conn closed","messagePattern":"conn closed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgconn/errors.go","lineNumber":100,"sourceCode":"type perDialConnectError struct {\n\taddress          string\n\toriginalHostname string\n\terr              error\n}\n\nfunc (e *perDialConnectError) Error() string {\n\treturn fmt.Sprintf(\"%s (%s): %s\", e.address, e.originalHostname, e.err.Error())\n}\n\nfunc (e *perDialConnectError) Unwrap() error {\n\treturn e.err\n}\n\n// ErrConnClosed is returned (possibly wrapped) when an operation is attempted\n// on a connection that the driver has already closed, e.g. because a prior\n// query was cancelled mid-flight or the underlying socket went away. Use\n// errors.Is to test for it, since it shows up wrapped inside connLockError.\nvar ErrConnClosed = errors.New(\"conn closed\")\n\ntype connLockError struct {\n\tstatus string\n}\n\nfunc (e *connLockError) SafeToRetry() bool {\n\treturn true // a lock failure by definition happens before the connection is used.\n}\n\nfunc (e *connLockError) Error() string {\n\treturn e.status\n}\n\nfunc (e *connLockError) Unwrap() error {\n\tif e.status == \"conn closed\" {\n\t\treturn ErrConnClosed\n\t}\n\treturn nil","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgconn/errors.go#L82-L118","documentation":"Error \"conn closed\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgconn/errors.go:100 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}