XTLS/Xray-core · error
unsupported address and port strategy:
Error message
unsupported address and port strategy:
What it means
Thrown while building SocketConfig when the 'addressPortStrategy' string inside 'sockopt' does not match any supported value. Accepted values (lowercase, as handled by the switch) include srvportonly, srvaddressonly, srvportandaddress, txtportonly, txtaddressonly, txtportandaddress (plus the other branches above the shown region). Any other string hits the default branch and fails the whole config build.
Source
Thrown at infra/conf/transport_sockopt.go:154
addressPortStrategy := internet.AddressPortStrategy_None
switch strings.ToLower(c.AddressPortStrategy) {
case "none", "":
addressPortStrategy = internet.AddressPortStrategy_None
case "srvportonly":
addressPortStrategy = internet.AddressPortStrategy_SrvPortOnly
case "srvaddressonly":
addressPortStrategy = internet.AddressPortStrategy_SrvAddressOnly
case "srvportandaddress":
addressPortStrategy = internet.AddressPortStrategy_SrvPortAndAddress
case "txtportonly":
addressPortStrategy = internet.AddressPortStrategy_TxtPortOnly
case "txtaddressonly":
addressPortStrategy = internet.AddressPortStrategy_TxtAddressOnly
case "txtportandaddress":
addressPortStrategy = internet.AddressPortStrategy_TxtPortAndAddress
default:
return nil, errors.New("unsupported address and port strategy: ", c.AddressPortStrategy)
}
happyEyeballs := &internet.HappyEyeballsConfig{Interleave: 1, PrioritizeIpv6: false, TryDelayMs: 0, MaxConcurrentTry: 4}
if c.HappyEyeballsSettings != nil {
happyEyeballs.PrioritizeIpv6 = c.HappyEyeballsSettings.PrioritizeIPv6
happyEyeballs.Interleave = c.HappyEyeballsSettings.Interleave
happyEyeballs.TryDelayMs = c.HappyEyeballsSettings.TryDelayMs
happyEyeballs.MaxConcurrentTry = c.HappyEyeballsSettings.MaxConcurrentTry
}
return &internet.SocketConfig{
Mark: c.Mark,
Tfo: tfo,
Tproxy: tproxy,
DomainStrategy: dStrategy,
AcceptProxyProtocol: c.AcceptProxyProtocol,
DialerProxy: c.DialerProxy,
TcpKeepAliveInterval: c.TCPKeepAliveInterval,View on GitHub (pinned to 7d214f8b09)
Solutions
- Use an exact literal: "srvportonly", "srvaddressonly", "srvportandaddress", "txtportonly", "txtaddressonly", "txtportandaddress" (lowercase)
- Remove the addressPortStrategy key if SRV/TXT-based resolution is not intended
Example fix
// before
"sockopt": { "addressPortStrategy": "SrvPortOnly" }
// after
"sockopt": { "addressPortStrategy": "srvportonly" } Defensive patterns
Strategy: validation
Validate before calling
var addressPortStrategies = map[string]bool{
"": true, "srvportonly": true, "srvaddressonly": true, "srvportandaddress": true,
"txtportonly": true, "txtaddressonly": true, "txtportandaddress": true,
}
if s, ok := sockopt["addressPortStrategy"]; ok {
if !addressPortStrategies[s.(string)] {
return fmt.Errorf("invalid sockopt.addressPortStrategy: %q", s)
}
} Prevention
- Copy the exact lowercase literal from the Xray docs
- Add a lint step that checks enum-like strings against allow-lists
When it happens
Trigger: Setting "sockopt": { "addressPortStrategy": "srv" }, "SrvPortOnly" (wrong case), or "txt" in streamSettings, then starting Xray or reloading config.
Common situations: Guessing/abbreviating the strategy name instead of copying the documented literal, using uppercase from documentation prose, or trailing spaces from copy-paste.
Related errors
- unsupported domain strategy:
- Unable to locate a fake DNS Engine
- failed to parse name server: {}
- nameserver address is not specified
- not an IP address:{}
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/e9cbea895171cb78.
Report an issue: GitHub.