slimtoolkit/slim · error
fcgi: invalid header version
Error message
fcgi: invalid header version
What it means
The internal FastCGI client reads response records whose header carries a protocol version byte; per the FastCGI spec it must be FCGI_VERSION_1. Any other version byte means the stream is not a valid FastCGI response, so the reader rejects it.
Source
Thrown at pkg/app/master/probe/http/internal/client.go:159
func (h *header) init(recType uint8, reqID uint16, contentLength int) {
h.Version = 1
h.Type = recType
h.ID = reqID
h.ContentLength = uint16(contentLength)
h.PaddingLength = uint8(-contentLength & 7)
}
type record struct {
h header
rbuf []byte
}
func (rec *record) read(r io.Reader) (buf []byte, err error) {
if err = binary.Read(r, binary.BigEndian, &rec.h); err != nil {
return
}
if rec.h.Version != 1 {
err = errors.New("fcgi: invalid header version")
return
}
if rec.h.Type == EndRequest {
err = io.EOF
return
}
n := int(rec.h.ContentLength) + int(rec.h.PaddingLength)
if len(rec.rbuf) < n {
rec.rbuf = make([]byte, n)
}
if _, err = io.ReadFull(r, rec.rbuf[:n]); err != nil {
return
}
buf = rec.rbuf[:int(rec.h.ContentLength)]
return
}
View on GitHub (pinned to 81940d17fa)
Solutions
- Confirm the target address/port speaks FastCGI (e.g. php-fpm on 9000), not HTTP
- Check what the server actually returned (error page, redirect, TLS handshake bytes)
- Fix the probe URL/scheme so it doesn't hit an HTTP-only endpoint
Example fix
// before probeURL = "http://svc:80/status" // plain HTTP // after probeURL = "fcgi://svc:9000/status" // FastCGI endpoint
Defensive patterns
Strategy: validation
Validate before calling
// verify the endpoint speaks FastCGI before probing
u, _ := url.Parse(probeURL)
if u.Scheme != "fcgi" { return fmt.Errorf("probe target must be fcgi://, got %s", u.Scheme) } Try / catch
body, err := client.Read()
if err != nil && strings.Contains(err.Error(), "invalid header version") {
return fmt.Errorf("endpoint did not return FastCGI records; check scheme/port: %w", err)
} Prevention
- Point probes at the FastCGI port (e.g. php-fpm 9000), not the HTTP port
- Don't route probes through plain-HTTP reverse proxies
- Confirm the backend's protocol before configuring the probe
When it happens
Trigger: Reading a record whose header version byte != 1 — typically because the endpoint returned plain HTTP/HTML (e.g. an error page) or a server speaking a different/incompatible protocol instead of FastCGI.
Common situations: Pointing the probe at a non-FastCGI port; a reverse proxy or web server responding with an HTTP error page; garbage/corrupted response bytes.
Related errors
- building environment: %v
- dialing backend: %v
- setting read timeout: %v
- setting write timeout: %v
- invalid ws proto - %s
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/c150e45d6675b336.
Report an issue: GitHub.