{"record":{"id":"57380702a6d21f8f","repo":"txthinking/brook","slug":"socks5-server-requires-a-clear-ip-for-udp-only-po-573807","errorCode":null,"errorMessage":"socks5 server requires a clear IP for UDP, only port is not enough. You may use public IP or lan IP or other, we can not decide for you","messagePattern":"socks5 server requires a clear IP for UDP, only port is not enough\\. You may use public IP or lan IP or other, we can not decide for you","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/brook/main.go","lineNumber":2349,"sourceCode":"\t\t\t\t&cli.BoolFlag{\n\t\t\t\t\tName:  \"example\",\n\t\t\t\t\tUsage: \"Show a minimal example of usage\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tAction: func(c *cli.Context) error {\n\t\t\t\tif c.Bool(\"example\") {\n\t\t\t\t\tfmt.Println(\"brook socks5 --listen :9999 --socks5ServerIP 1.2.3.4\")\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tif c.String(\"listen\") == \"\" {\n\t\t\t\t\treturn cli.ShowSubcommandHelp(c)\n\t\t\t\t}\n\t\t\t\th, _, err := net.SplitHostPort(c.String(\"listen\"))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif h == \"\" && c.String(\"socks5ServerIP\") == \"\" {\n\t\t\t\t\treturn errors.New(\"socks5 server requires a clear IP for UDP, only port is not enough. You may use public IP or lan IP or other, we can not decide for you\")\n\t\t\t\t}\n\t\t\t\tvar ip string\n\t\t\t\tif h != \"\" {\n\t\t\t\t\tip = h\n\t\t\t\t}\n\t\t\t\tif c.String(\"socks5ServerIP\") != \"\" {\n\t\t\t\t\tip = c.String(\"socks5ServerIP\")\n\t\t\t\t}\n\t\t\t\ts, err := brook.NewSocks5Server(c.String(\"listen\"), ip, c.String(\"username\"), c.String(\"password\"), c.Int(\"tcpTimeout\"), c.Int(\"udpTimeout\"))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\ts.Server.LimitUDP = c.Bool(\"limitUDP\")\n\t\t\t\tg.Add(&runnergroup.Runner{\n\t\t\t\t\tStart: func() error {\n\t\t\t\t\t\treturn s.ListenAndServe()\n\t\t\t\t\t},\n\t\t\t\t\tStop: func() error {","sourceCodeStart":2331,"sourceCodeEnd":2367,"githubUrl":"https://github.com/txthinking/brook/blob/5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8/cli/brook/main.go#L2331-L2367","documentation":"Like error 40 but for a different socks5 server path: the socks5 listener needs a concrete host IP so UDP relay replies know where to originate/advertise. When net.SplitHostPort yields an empty host and --socks5ServerIP is also empty, brook throws this error, asking for a public or LAN IP it cannot infer.","triggerScenarios":"Running the socks5 server subcommand with a port-only listen value such as `-l :1080` and no --socks5ServerIP, hitting the check at cli/brook/main.go:2349.","commonSituations":"Container deployments where users bind on all interfaces with `:port`; scripts that only parameterize the port; users assuming brook will auto-detect the public IP (it deliberately will not).","solutions":["Bind with an explicit host: `-l 0.0.0.0:1080` or your LAN/public IP","Supply --socks5ServerIP with the address UDP clients should use (e.g. the machine's public IP)","Document the intended IP in your deployment template so the flag is never omitted"],"exampleFix":"// before\nbrook socks5 -l :1080\n// after\nbrook socks5 -l :1080 --socks5ServerIP 203.0.113.10","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Auto-detect the primary interface IP in wrapper scripts and pass it as --socks5ServerIP"],"tags":["cli","network","udp","socks5"],"backgroundTag":"missing-required-config-field","analyzedSha":"5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8","analyzedAt":"2026-09-06T04:35:00.432Z","contentChangedAt":"2026-09-06T04:35:00.432Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}