jackc/pgx · error
Bad startup message version number. Expected %d or %d, got %
Error message
Bad startup message version number. Expected %d or %d, got %d
What it means
Error "Bad startup message version number. Expected %d or %d, got %d" thrown in jackc/pgx.
Source
Thrown at pgproto3/startup_message.go:39
ProtocolVersion uint32
Parameters map[string]string
}
// Frontend identifies this message as sendable by a PostgreSQL frontend.
func (*StartupMessage) Frontend() {}
// Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
// type identifier and 4 byte message length.
func (dst *StartupMessage) Decode(src []byte) error {
if len(src) < 4 {
return errors.New("startup message too short")
}
dst.ProtocolVersion = binary.BigEndian.Uint32(src)
rp := 4
if dst.ProtocolVersion != ProtocolVersion30 && dst.ProtocolVersion != ProtocolVersion32 {
return fmt.Errorf("Bad startup message version number. Expected %d or %d, got %d", ProtocolVersion30, ProtocolVersion32, dst.ProtocolVersion)
}
dst.Parameters = make(map[string]string)
for {
idx := bytes.IndexByte(src[rp:], 0)
if idx < 0 {
return &invalidMessageFormatErr{messageType: "StartupMessage"}
}
key := string(src[rp : rp+idx])
rp += idx + 1
idx = bytes.IndexByte(src[rp:], 0)
if idx < 0 {
return &invalidMessageFormatErr{messageType: "StartupMessage"}
}
value := string(src[rp : rp+idx])
rp += idx + 1
View on GitHub (pinned to ec1a0befd2)
When it happens
Trigger: Thrown at pgproto3/startup_message.go:39 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/f0f456479985cb42.json.
Report an issue: GitHub.