XTLS/Xray-core · error
Invalid Shadowsocks port.
Error message
Invalid Shadowsocks port.
What it means
While building the 2022 Shadowsocks outbound client config, the destination port must be a non-zero value. Since port 0 is never a valid remote endpoint, the builder rejects it before creating the ClientConfig.
Source
Thrown at infra/conf/shadowsocks.go:224
Level: v.Level,
Email: v.Email,
Cipher: v.Cipher,
Password: v.Password,
},
}
}
if len(v.Servers) != 1 {
return nil, errors.New(`Shadowsocks settings: "servers" should have one and only one member. Multiple endpoints in "servers" should use multiple Shadowsocks outbounds and routing balancer instead`)
}
if len(v.Servers) == 1 {
server := v.Servers[0]
if C.Contains(shadowaead_2022.List, server.Cipher) {
if server.Address == nil {
return nil, errors.New("Shadowsocks server address is not set.")
}
if server.Port == 0 {
return nil, errors.New("Invalid Shadowsocks port.")
}
if server.Password == "" {
return nil, errors.New("Shadowsocks password is not specified.")
}
config := new(shadowsocks_2022.ClientConfig)
config.Address = server.Address.Build()
config.Port = uint32(server.Port)
config.Method = server.Cipher
config.Key = server.Password
return config, nil
}
}
config := new(shadowsocks.ClientConfig)
for _, server := range v.Servers {
if C.Contains(shadowaead_2022.List, server.Cipher) {
return nil, errors.New("Shadowsocks 2022 accept no multi servers")View on GitHub (pinned to 7d214f8b09)
Solutions
- Set 'port' to the server's actual TCP/UDP port (1-65535).
- Check that templating/output did not zero the port value.
- Confirm port is a number, not a string.
Example fix
// before
{"address": "example.com", "method": "2022-blake3-aes-256-gcm", "password": "..."}
// after
{"address": "example.com", "port": 443, "method": "2022-blake3-aes-256-gcm", "password": "..."} Defensive patterns
Strategy: validation
Validate before calling
func validPort(p any) bool {
n, ok := p.(float64)
return ok && n >= 1 && n <= 65535
} Prevention
- Always set explicit ports; treat 0 as invalid in generators
When it happens
Trigger: A 2022-method servers entry that omits 'port' or sets it to 0: {"address": "example.com", "method": "2022-blake3-aes-256-gcm", "password": "..."} with no port.
Common situations: Config snippets that show only address/password; port accidentally set to 0 in generated configs; YAML treating an unquoted value oddly.
Related errors
- invalid redirect port: {}
- Shadowsocks server address is not set.
- Shadowsocks 2022 accept no multi servers
- failed to get outbound handler with tag: ${tag}
- existing tag found: ${tag}
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/509e490aee2ef1d3.
Report an issue: GitHub.