{"record":{"id":"414d26dba2909a1b","repo":"OpenNHP/opennhp","slug":"resolve-udpaddr-error-v","errorCode":null,"errorMessage":"resolve UDPAddr error %v","messagePattern":"resolve UDPAddr error (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/server/udpserver.go","lineNumber":260,"sourceCode":"\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 {\n\t\tlog.Error(\"resolve local UDPAddr error: %v\", err)\n\t\treturn fmt.Errorf(\"resolve UDPAddr error %v\", err)\n\t}\n\n\tprk, err := base64.StdEncoding.DecodeString(s.config.PrivateKeyBase64)\n\tif err != nil {\n\t\tlog.Error(\"private key parse error: %v\", err)\n\t\treturn fmt.Errorf(\"private key parse error %v\", err)\n\t}\n\n\toption := &core.DeviceOptions{\n\t\tDisableAgentPeerValidation: s.config.DisableAgentValidation,\n\t}\n\ts.device = core.NewDevice(core.NHP_SERVER, prk, option)\n\tif s.device == nil {\n\t\tlog.Critical(\"failed to create device: %v\", err)\n\t\treturn fmt.Errorf(\"failed to create device %v\", err)\n\t}\n\n\t// Stateless cookie signing key. In a multi-instance cluster all","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/server/udpserver.go#L242-L278","documentation":"After a successful ListenUDP, Start resolves the local address back into a *net.UDPAddr and stores it as s.listenAddr. Failure of net.ResolveUDPAddr here is unexpected (the kernel just reported a valid socket), so this error indicates an internal anomaly in address parsing.","triggerScenarios":"net.ResolveUDPAddr fails on the string returned by listenConn.LocalAddr(), e.g. malformed or unsupported network/address string from the OS.","commonSituations":"Rare; exotic platforms or environments returning unusual LocalAddr formats; usually indicates a Go runtime/OS-level quirk rather than user misconfiguration.","solutions":["Retry startup; this is typically transient or environment-specific","Log and inspect laddr.String() and laddr.Network() to see what failed to parse","Upgrade Go runtime if the OS returns an unusual address format","Report upstream with the OS and address string if reproducible"],"exampleFix":"// debug aid\nlog.Info(\"local addr: network=%s string=%s\", laddr.Network(), laddr.String())","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := server.Start(); err != nil {\n    if strings.Contains(err.Error(), \"resolve UDPAddr error\") {\n        return retryWithBackoff(server.Start, 3)\n    }\n    return err\n}","preventionTips":["Keep the Go toolchain current","Treat this as an environment anomaly; capture LocalAddr output for bug reports"],"tags":["udp","startup","resolution","internal"],"backgroundTag":"internal-invariant-violation","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"}