{"record":{"id":"975c1eb002d75b17","repo":"XTLS/Xray-core","slug":"failed-to-determine-if-address-is-local-err","errorCode":null,"errorMessage":"failed to determine if address is local: {err}","messagePattern":"failed to determine if address is local: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/net/find_process_windows.go","lineNumber":62,"sourceCode":"\n\tgetExUDPTable, err = windows.GetProcAddress(h, udpTableFunc)\n\tif err != nil {\n\t\treturn errors.New(\"GetProcAddress of \", udpTableFunc, \" failed\").Base(err)\n\t}\n\n\treturn nil\n}\n\nfunc FindProcess(network, srcIP string, srcPort uint16, destIP string, destPort uint16) (PID int, Name string, AbsolutePath string, err error) {\n\tonce.Do(func() {\n\t\tinitErr = initWin32API()\n\t})\n\tif initErr != nil {\n\t\treturn 0, \"\", \"\", initErr\n\t}\n\tisLocal, err := IsLocal(net.ParseIP(srcIP))\n\tif err != nil {\n\t\treturn 0, \"\", \"\", errors.New(\"failed to determine if address is local: \", err)\n\t}\n\tif !isLocal {\n\t\treturn 0, \"\", \"\", ErrNotLocal\n\t}\n\tif network != \"tcp\" && network != \"udp\" {\n\t\tpanic(\"Unsupported network type for process lookup.\")\n\t}\n\tvar class int\n\tvar fn uintptr\n\tswitch network {\n\tcase \"tcp\":\n\t\tfn = getExTCPTable\n\t\tclass = tcpTablePidConn\n\tcase \"udp\":\n\t\tfn = getExUDPTable\n\t\tclass = udpTablePid\n\tdefault:\n\t\tpanic(\"Unsupported network type for process lookup.\")","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/common/net/find_process_windows.go#L44-L80","documentation":"Windows FindProcess checks that srcIP is local via IsLocal before consulting the IP Helper tables; that interface enumeration failed and the wrapped error follows the colon (message template shows '{err}'). Without confirming the address is local, the GetExtended{Tcp,Udp}Table search cannot proceed.","triggerScenarios":"net.Interfaces() failing on Windows (rare): broken Winsock catalog, NIC driver in a bad state, or srcIP malformed so net.ParseIP(srcIP) returned nil and IsLocal received a nil IP.","commonSituations":"Passing empty/invalid srcIP from upstream metadata; systems with a corrupted Winsock stack (fixable with netsh winsock reset); VPN virtual adapters in transition states.","solutions":["Validate srcIP with net.ParseIP != nil before calling FindProcess","If interface enumeration is genuinely broken, run 'netsh winsock reset' and reboot","Disable/re-enable the suspect virtual adapter (VPN filters often break GetAdaptersAddresses mid-transition)","Fall back to routing rules that do not need the process"],"exampleFix":"// before\npid, name, path, err := net.FindProcess(network, srcIP, srcPort, dstIP, dstPort)\n\n// after\nif net.ParseIP(srcIP) == nil {\n    return errors.New(\"invalid srcIP: \", srcIP)\n}\npid, name, path, err := net.FindProcess(network, srcIP, srcPort, dstIP, dstPort)","handlingStrategy":"try-catch","validationCode":"if net.ParseIP(srcIP) == nil {\n    return errors.New(\"invalid srcIP: \", srcIP) // nil IP breaks IsLocal\n}\nif _, err := net.Interfaces(); err != nil {\n    // Winsock/interface stack unhealthy; lookup will fail\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to determine if address is local\") {\n    // environment/input issue, not a routing miss; skip process rules\n}","preventionTips":["Validate srcIP before calling — nil IPs reach IsLocal silently on Windows too","Run 'netsh winsock reset' when interface enumeration errors appear","Cache the failure; the interface stack will not recover within the process"],"tags":["windows","process-lookup","network-interfaces","input-validation"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}