openfaas/faas · error
invalid value for max_idle_conns_per_host: %s
Error message
invalid value for max_idle_conns_per_host: %s
What it means
Thrown by ReadConfig in gateway/types/readconfig.go at startup when the max_idle_conns_per_host environment variable is set but is not a plain base-10 integer (strconv.Atoi fails). ReadConfig returns the error and the gateway process fails to boot. Leaving the variable unset is safe: the default of 1024 applies.
Source
Thrown at gateway/types/readconfig.go:159
cfg.MaxIdleConns = 1024
cfg.MaxIdleConnsPerHost = 1024
maxIdleConns := hasEnv.Getenv("max_idle_conns")
if len(maxIdleConns) > 0 {
val, err := strconv.Atoi(maxIdleConns)
if err != nil {
return nil, fmt.Errorf("invalid value for max_idle_conns: %s", maxIdleConns)
}
cfg.MaxIdleConns = val
}
maxIdleConnsPerHost := hasEnv.Getenv("max_idle_conns_per_host")
if len(maxIdleConnsPerHost) > 0 {
val, err := strconv.Atoi(maxIdleConnsPerHost)
if err != nil {
return nil, fmt.Errorf("invalid value for max_idle_conns_per_host: %s", maxIdleConnsPerHost)
}
cfg.MaxIdleConnsPerHost = val
}
cfg.AuthProxyURL = hasEnv.Getenv("auth_proxy_url")
cfg.AuthProxyPassBody = parseBoolValue(hasEnv.Getenv("auth_proxy_pass_body"))
cfg.Namespace = hasEnv.Getenv("function_namespace")
return &cfg, nil
}
// GatewayConfig provides config for the API Gateway server process
type GatewayConfig struct {
// HTTP timeout for reading a request from clients.
ReadTimeout time.DurationView on GitHub (pinned to 8d803bf9e2)
Solutions
- Set max_idle_conns_per_host to a bare decimal integer, e.g. max_idle_conns_per_host=256
- Remove the variable to fall back to the default of 1024
- Check the manifest/ConfigMap for whitespace, commas or unit suffixes in the value
- Validate both *_conns variables against ^[0-9]+$ in CI
Example fix
# before max_idle_conns_per_host: "256Mi" # after max_idle_conns_per_host: "256"
Defensive patterns
Strategy: validation
Validate before calling
# validate before deploying the gateway if [ -n "$max_idle_conns_per_host" ] && ! [[ "$max_idle_conns_per_host" =~ ^[0-9]+$ ]]; then echo "max_idle_conns_per_host must be an integer, got: $max_idle_conns_per_host" >&2 exit 1 fi
Type guard
func isBase10Int(s string) bool {
_, err := strconv.Atoi(s)
return err == nil
} Prevention
- Never use memory-size suffixes (Mi, k) on connection-count variables
- Render and inspect the final env with kubectl describe pod before rollout
- Add schema validation for gateway env vars in Helm values tests
When it happens
Trigger: Setting max_idle_conns_per_host to a non-integer value such as "256 " with trailing whitespace, "1,024", "0.5", "1e2" or "per-host" via kubectl, Helm values, docker-compose environment or a ConfigMap entry with a stray newline.
Common situations: Copying a documented example with a comma separator; ConfigMap block scalars adding trailing newlines; CI templating injecting whitespace; confusing the variable with a memory-size style value like "256Mi".
Related errors
- invalid value for max_idle_conns: %s
- A body is required for this endpoint
- err.Error()
- Unable to parse list of functions from provider
AI-assisted analysis of openfaas/faas@8d803bf9e2 (2026-08-16).
Data as JSON: /api/errors/f09618e54fad1b4b.
Report an issue: GitHub.