XTLS/Xray-core · error
invalid redirect address: {}
Error message
invalid redirect address: {} What it means
Thrown while building a freedom outbound whose 'redirect' string cannot be split into host and port by net.SplitHostPort. Redirect must be a dialable address like "example.com:443" or ":8443"; the chained base error carries the exact SplitHostPort failure (missing port, too many colons, etc.).
Source
Thrown at infra/conf/freedom.go:164
return nil, errors.PrintRemovedFeatureError("noise = { ... }", "noises = [ { ... } ]")
}
if c.Noises != nil {
for _, n := range c.Noises {
NConfig, err := ParseNoise(n)
if err != nil {
return nil, err
}
config.Noises = append(config.Noises, NConfig)
}
}
config.UserLevel = c.UserLevel
if len(c.Redirect) > 0 {
host, portStr, err := net.SplitHostPort(c.Redirect)
if err != nil {
return nil, errors.New("invalid redirect address: ", c.Redirect, ": ", err).Base(err)
}
port, err := xnet.PortFromString(portStr)
if err != nil {
return nil, errors.New("invalid redirect port: ", c.Redirect, ": ", err).Base(err)
}
config.DestinationOverride = &freedom.DestinationOverride{
Server: &protocol.ServerEndpoint{
Port: uint32(port),
},
}
if len(host) > 0 {
config.DestinationOverride.Server.Address = xnet.NewIPOrDomain(xnet.ParseAddress(host))
}
}
if c.ProxyProtocol > 0 && c.ProxyProtocol <= 2 {
config.ProxyProtocol = c.ProxyProtocolView on GitHub (pinned to 7d214f8b09)
Solutions
- Format redirect as "host:port", e.g. "example.com:443"; a bare ":8080" redirects port only.
- Bracket IPv6: "[2001:db8::1]:443".
- Check the base error text for the precise reason (missing port vs. too many colons).
Example fix
// before "redirect": "example.com" // after "redirect": "example.com:443"
Defensive patterns
Strategy: validation
Validate before calling
if _, _, err := net.SplitHostPort(redirect); err != nil {
return fmt.Errorf("redirect %q must be host:port: %w", redirect, err)
} Prevention
- Always include the port in redirect; bracket IPv6 hosts.
- Reuse one validated address formatter for redirect fields.
When it happens
Trigger: "redirect": "example.com" (no port), "redirect": "127.0.0.1:80:443", or an unbracketed IPv6 "::1:443". Any value for which SplitHostPort errors triggers it.
Common situations: Forgetting the port; pasting bare domains; IPv6 literals without square brackets; redirect copied from a browser URL with a path appended.
Related errors
- unsupported domain strategy: {}
- invalid redirect port: {}
- Invalid PacketsFrom
- invalid value for rand Length
- Invalid hex string
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/df8e60f0a72465d9.
Report an issue: GitHub.