{"record":{"id":"2641a5c2c4ccd20f","repo":"OpenNHP/opennhp","slug":"udp-listen-ip-address-is-incorrect","errorCode":null,"errorMessage":"udp listen ip address is incorrect","messagePattern":"udp listen ip address is incorrect","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"endpoints/server/udpserver.go","lineNumber":240,"sourceCode":"\t// load remote config,init etcd client\n\terr = s.initRemoteConn()\n\tif err == nil && s.etcdConn == nil {\n\t\t// init config\n\t\terr = s.loadBaseConfig()\n\t} else {\n\t\t// nhp server base config must be loaded first.\n\t\terr = s.loadRemoteBaseConfig()\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar netIP net.IP\n\tif len(s.config.ListenIp) > 0 {\n\t\tnetIP = net.ParseIP(s.config.ListenIp)\n\t\tif netIP == nil {\n\t\t\tlog.Error(\"udp listen ip address is incorrect!\")\n\t\t\treturn fmt.Errorf(\"udp listen ip address is incorrect\")\n\t\t}\n\t} else {\n\t\tnetIP = net.IPv4zero // will both listen on ipv4 0.0.0.0:port and ipv6 [::]:port\n\t}\n\n\ts.listenConn, err = net.ListenUDP(\"udp\", &net.UDPAddr{\n\t\tIP:   netIP,\n\t\tPort: s.config.ListenPort,\n\t})\n\tif err != nil {\n\t\tlog.Error(\"listen error: %v\", err)\n\t\treturn fmt.Errorf(\"listen error %v\", err)\n\t}\n\n\t// retrieve local port\n\tladdr := s.listenConn.LocalAddr()\n\ts.listenAddr, err = net.ResolveUDPAddr(laddr.Network(), laddr.String())\n\tif err != nil {","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/server/udpserver.go#L222-L258","documentation":"UdpServer.Start validates config.ListenIp with net.ParseIP before binding. If the configured IP string is not a valid IP literal, startup aborts with this error. An empty ListenIp is allowed and falls back to IPv4zero (all interfaces).","triggerScenarios":"config.toml contains listenIp with a hostname, an invalid string like '0.0.0:9999', or a typo such as '127.0.0.1.1'.","commonSituations":"Operator putting a DNS name in listenIp instead of an IP; copy-paste errors in config; environment-specific config rendering mistakes.","solutions":["Set listenIp to a valid IP literal (e.g. 0.0.0.0, ::, or a specific interface IP)","Leave listenIp empty to listen on all interfaces","Use net.ParseIP on the value to verify before deploying","If a hostname is needed, resolve it to an IP first (or extend config to resolve)"],"exampleFix":"// before (config.toml)\nlistenIp = \"nhp.example.com\"\n// after\nlistenIp = \"0.0.0.0\"","handlingStrategy":"validation","validationCode":"if cfg.ListenIp != \"\" && net.ParseIP(cfg.ListenIp) == nil {\n    return fmt.Errorf(\"listenIp %q is not a valid IP literal\", cfg.ListenIp)\n}","typeGuard":null,"tryCatchPattern":"if err := server.Start(); err != nil {\n    if strings.Contains(err.Error(), \"ip address is incorrect\") {\n        return fmt.Errorf(\"fix listenIp in config.toml: %w\", err)\n    }\n    return err\n}","preventionTips":["Always use IP literals, not hostnames, in listenIp","Leave listenIp empty for all interfaces","Validate config with net.ParseIP before deploy"],"tags":["config","udp","startup","invalid-ip"],"backgroundTag":"invalid-config-value","analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}