jackc/pgx · error
invalid protocol version
Error message
invalid protocol version: %q
What it means
The protocol_version connection parameter was not one of the accepted values. Valid values are "3.0", "3.2", and "latest" (empty defaults to 3.0). The %q shows the rejected input.
Solutions
- Set protocol_version to "3.0", "3.2", or "latest"
- Remove the parameter to use the default (3.0)
- Check for typos in the connection string
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pgconn/config.go:1117 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/8c48c4656e020ae2.
Report an issue: GitHub.
Appendix: source
Thrown at pgconn/config.go:1117
if err != nil {
return err
}
if string(result[0].Rows[0][0]) != "t" {
return &NotPreferredError{err: errors.New("server is not in hot standby mode")}
}
return nil
}
func parseProtocolVersion(s string) (uint32, error) {
switch s {
case "", "3.0":
return pgproto3.ProtocolVersion30, nil
case "3.2", "latest":
return pgproto3.ProtocolVersion32, nil
default:
return 0, fmt.Errorf("invalid protocol version: %q", s)
}
}
View on GitHub (pinned to ec1a0befd2)