fatedier/frp · error
%s: port number %d must be in the range 0..65535
Error message
%s: port number %d must be in the range 0..65535
What it means
ValidatePort rejects any port outside 0..65535. It is the shared range check used across frp config validation (webServer.port here, and reused for bind/local/remote ports elsewhere), with the field path interpolated so the message names which config key is wrong.
Source
Thrown at pkg/config/v1/validation/common.go:42
func validateWebServerConfig(c *v1.WebServerConfig) error {
if c.TLS != nil {
if c.TLS.CertFile == "" {
return fmt.Errorf("tls.certFile must be specified when tls is enabled")
}
if c.TLS.KeyFile == "" {
return fmt.Errorf("tls.keyFile must be specified when tls is enabled")
}
}
return ValidatePort(c.Port, "webServer.port")
}
// ValidatePort checks that the network port is in range
func ValidatePort(port int, fieldPath string) error {
if 0 <= port && port <= 65535 {
return nil
}
return fmt.Errorf("%s: port number %d must be in the range 0..65535", fieldPath, port)
}
func validateLogConfig(c *v1.LogConfig) error {
if !slices.Contains(SupportedLogLevels, c.Level) {
return fmt.Errorf("invalid log level, optional values are %v", SupportedLogLevels)
}
return nil
}
View on GitHub (pinned to 6c8a8d0a97)
Solutions
- Set the named port field to a value in 0..65535 (prefer 1024+ for non-root)
- If the value comes from env/flags, bounds-check before feeding it into config
- Check for accidental string concatenation (e.g. "7400" + "0") in templated configs
Example fix
# before [webServer] port = 740000 # after [webServer] port = 7400
Defensive patterns
Strategy: validation
Validate before calling
func portInRange(p int) bool { return p >= 0 && p <= 65535 }
// or reuse: validation.ValidatePort(p, "field") Prevention
- Bounds-check env/flag-derived ports with strconv + range check before writing config
- Use validation.ValidatePort directly in custom tooling
When it happens
Trigger: webServer.port = 70000 or a negative value; also triggered via other call sites that pass their own fieldPath (e.g. proxy localPort). Integer overflow from env-var parsing (strconv without bounds) often lands here.
Common situations: Ports passed via environment variables or CLI flags parsed as int without range checks; YAML unquoted values interpreted oddly; copying a port from a URL like :808080.
Related errors
- exec configuration is required when type is 'exec'
- file path cannot be empty
- exec command cannot be empty
- exec env name cannot be empty
- exec env name cannot contain '='
AI-assisted analysis of fatedier/frp@6c8a8d0a97 (2026-08-15).
Data as JSON: /api/errors/f497f8ee63922148.
Report an issue: GitHub.