jackc/pgx · error

require_auth method is specified more than once

Error message

require_auth method %q is specified more than once

What it means

The same auth method appears more than once in the require_auth list, which is ambiguous and rejected. This includes repeating a method within the same negation style.

Solutions

  1. Remove the duplicate method from require_auth
  2. List each method at most once
  3. Check for accidental double entry when editing the connection string
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pgconn/require_auth.go:128 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: /api/errors/427c5776b8607558. Report an issue: GitHub.

Appendix: source

Thrown at pgconn/require_auth.go:128

			m = authMethodMD5
		case "gss":
			m = authMethodGSS
		case "sspi":
			m = authMethodSSPI
		case "scram-sha-256":
			m = authMethodSCRAMSHA256
		case "oauth":
			m = authMethodOAuth
		case "none":
			m = authMethodNone
		default:
			return requireAuth{}, fmt.Errorf("invalid require_auth method: %q", method)
		}

		bit := uint8(1) << m
		if negated {
			if ra.allowed&bit == 0 {
				return requireAuth{}, fmt.Errorf("require_auth method %q is specified more than once", part)
			}
			ra.allowed &^= bit
			if m == authMethodNone {
				ra.authRequired = true
			}
		} else {
			if ra.allowed&bit != 0 {
				return requireAuth{}, fmt.Errorf("require_auth method %q is specified more than once", part)
			}
			ra.allowed |= bit
			if m == authMethodNone {
				ra.authRequired = false
			}
		}
	}

	return ra, nil
}

View on GitHub (pinned to ec1a0befd2)