fatedier/frp · error
bind port is required
Error message
bind port is required
What it means
Validation error from validateVisitorBaseConfig: a visitor entry has bindPort set to 0 (the Go zero value for an unset port). The visitor listens locally on bindAddr:bindPort to expose the remote service, so an explicit non-zero local port is mandatory. Third check in visitor base validation.
Source
Thrown at pkg/config/v1/validation/visitor.go:52
case *v1.XTCPVisitorConfig:
return validateXTCPVisitorConfig(v)
default:
return errors.New("unknown visitor config type")
}
return nil
}
func validateVisitorBaseConfig(c *v1.VisitorBaseConfig) error {
if c.Name == "" {
return errors.New("name is required")
}
if c.ServerName == "" {
return errors.New("server name is required")
}
if c.BindPort == 0 {
return errors.New("bind port is required")
}
return nil
}
func validateXTCPVisitorConfig(c *v1.XTCPVisitorConfig) error {
if !slices.Contains([]string{"kcp", "quic"}, c.Protocol) {
return fmt.Errorf("protocol should be kcp or quic")
}
return nil
}
View on GitHub (pinned to 6c8a8d0a97)
Solutions
- Add bindPort = 9000 (a free local TCP port) to the visitor entry.
- Also set bindAddr = "127.0.0.1" if you want the visitor loopback-only (bindAddr itself is optional with a default).
- Check the port is not already in use on the machine running frpc.
Example fix
# before [[visitors]] name = "v" type = "stcp" serverName = "stcp-srv" secretKey = "s" bindAddr = "127.0.0.1" # after [[visitors]] name = "v" type = "stcp" serverName = "stcp-srv" secretKey = "s" bindAddr = "127.0.0.1" bindPort = 9000
Defensive patterns
Strategy: validation
Validate before calling
base := v.GetBaseConfig()
if base == nil || base.BindPort == 0 {
return errors.New("visitor requires an explicit non-zero bindPort")
} Type guard
func visitorBindPortSet(c v1.VisitorConfigurer) bool {
base := c.GetBaseConfig()
return c != nil && base != nil && base.BindPort != 0
} Try / catch
if err := validation.ValidateVisitorConfigurer(v); err != nil {
if strings.Contains(err.Error(), "bind port is required") {
// choose a free local port and set bindPort
}
return err
} Prevention
- Visitors need a concrete local port; port 0 / random is not supported.
- Template visitors with name/type/serverName/secretKey/bindAddr/bindPort.
- Check for port collisions with other local listeners.
When it happens
Trigger: A [[visitors]] entry with bindPort omitted or set to 0. Note 0 is treated as 'missing', so a genuine desire to use port 0 (random port) is rejected — frp requires a concrete port.
Common situations: Copying a proxy block (which uses remotePort) and forgetting visitors need bindPort; assuming frpc picks a free port automatically; TOML key typo BindPort/bindport; programmatic configs leaving VisitorBaseConfig.BindPort unset.
Related errors
- name is required
- server name is required
- type shouldn't be empty
- type [%s] error
- visitor plugin type is empty
AI-assisted analysis of fatedier/frp@6c8a8d0a97 (2026-08-15).
Data as JSON: /api/errors/0160a3ab7dfb4ffb.
Report an issue: GitHub.