jackc/pgx · error

conn closed

Error message

conn closed

What it means

Error "conn closed" thrown in jackc/pgx.

Source

Thrown at pgconn/errors.go:100

type perDialConnectError struct {
	address          string
	originalHostname string
	err              error
}

func (e *perDialConnectError) Error() string {
	return fmt.Sprintf("%s (%s): %s", e.address, e.originalHostname, e.err.Error())
}

func (e *perDialConnectError) Unwrap() error {
	return e.err
}

// ErrConnClosed is returned (possibly wrapped) when an operation is attempted
// on a connection that the driver has already closed, e.g. because a prior
// query was cancelled mid-flight or the underlying socket went away. Use
// errors.Is to test for it, since it shows up wrapped inside connLockError.
var ErrConnClosed = errors.New("conn closed")

type connLockError struct {
	status string
}

func (e *connLockError) SafeToRetry() bool {
	return true // a lock failure by definition happens before the connection is used.
}

func (e *connLockError) Error() string {
	return e.status
}

func (e *connLockError) Unwrap() error {
	if e.status == "conn closed" {
		return ErrConnClosed
	}
	return nil

View on GitHub (pinned to ec1a0befd2)

When it happens

Trigger: Thrown at pgconn/errors.go:100 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04). Data as JSON: /data/errors/1d3b5c0d40fb9e0b.json. Report an issue: GitHub.