{"record":{"id":"509e490aee2ef1d3","repo":"XTLS/Xray-core","slug":"invalid-shadowsocks-port","errorCode":null,"errorMessage":"Invalid Shadowsocks port.","messagePattern":"Invalid Shadowsocks port\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/shadowsocks.go","lineNumber":224,"sourceCode":"\t\t\t\tLevel:    v.Level,\n\t\t\t\tEmail:    v.Email,\n\t\t\t\tCipher:   v.Cipher,\n\t\t\t\tPassword: v.Password,\n\t\t\t},\n\t\t}\n\t}\n\tif len(v.Servers) != 1 {\n\t\treturn 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`)\n\t}\n\n\tif len(v.Servers) == 1 {\n\t\tserver := v.Servers[0]\n\t\tif C.Contains(shadowaead_2022.List, server.Cipher) {\n\t\t\tif server.Address == nil {\n\t\t\t\treturn nil, errors.New(\"Shadowsocks server address is not set.\")\n\t\t\t}\n\t\t\tif server.Port == 0 {\n\t\t\t\treturn nil, errors.New(\"Invalid Shadowsocks port.\")\n\t\t\t}\n\t\t\tif server.Password == \"\" {\n\t\t\t\treturn nil, errors.New(\"Shadowsocks password is not specified.\")\n\t\t\t}\n\n\t\t\tconfig := new(shadowsocks_2022.ClientConfig)\n\t\t\tconfig.Address = server.Address.Build()\n\t\t\tconfig.Port = uint32(server.Port)\n\t\t\tconfig.Method = server.Cipher\n\t\t\tconfig.Key = server.Password\n\t\t\treturn config, nil\n\t\t}\n\t}\n\n\tconfig := new(shadowsocks.ClientConfig)\n\tfor _, server := range v.Servers {\n\t\tif C.Contains(shadowaead_2022.List, server.Cipher) {\n\t\t\treturn nil, errors.New(\"Shadowsocks 2022 accept no multi servers\")","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/shadowsocks.go#L206-L242","documentation":"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.","triggerScenarios":"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.","commonSituations":"Config snippets that show only address/password; port accidentally set to 0 in generated configs; YAML treating an unquoted value oddly.","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."],"exampleFix":"// before\n{\"address\": \"example.com\", \"method\": \"2022-blake3-aes-256-gcm\", \"password\": \"...\"}\n\n// after\n{\"address\": \"example.com\", \"port\": 443, \"method\": \"2022-blake3-aes-256-gcm\", \"password\": \"...\"}","handlingStrategy":"validation","validationCode":"func validPort(p any) bool {\n    n, ok := p.(float64)\n    return ok && n >= 1 && n <= 65535\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set explicit ports; treat 0 as invalid in generators"],"tags":["shadowsocks-2022","outbound","port","config"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}