{"record":{"id":"8780b818e4971ad1","repo":"XTLS/Xray-core","slug":"failed-to-get-ip-address-for-domain-domain","errorCode":null,"errorMessage":"failed to get IP address for domain {domain}","messagePattern":"failed to get IP address for domain (.+?)","errorType":"exception","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"proxy/freedom/freedom.go","lineNumber":322,"sourceCode":"\t\t\t\t\tAddress: net.IPAddress(ips[dice.Roll(len(ips))]),\n\t\t\t\t\tPort:    dialDest.Port,\n\t\t\t\t}\n\t\t\t\terrors.LogInfo(ctx, \"dialing to \", dialDest)\n\t\t\t}\n\t\t} else if h.shouldResolveDomainBeforeFinalRules(dialDest, defaultRule) { // asis + domain + hasrules\n\t\t\tdomain := dialDest.Address.Domain()\n\t\t\tvar ips []net.IP\n\t\t\tif firstResolve {\n\t\t\t\tfirstResolve = false\n\t\t\t\tsupportIPv4, supportIPv6 := utils.CheckRoutes()\n\t\t\t\tif supportIPv4 {\n\t\t\t\t\tips, _ = net.DefaultResolver.LookupIP(ctx, \"ip4\", domain)\n\t\t\t\t}\n\t\t\t\tif len(ips) == 0 && supportIPv6 {\n\t\t\t\t\tips, _ = net.DefaultResolver.LookupIP(ctx, \"ip6\", domain)\n\t\t\t\t}\n\t\t\t\tif len(ips) == 0 {\n\t\t\t\t\treturn errors.New(\"failed to get IP address for domain \", domain)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tips, _ = net.DefaultResolver.LookupIP(ctx, \"ip\", domain)\n\t\t\t}\n\t\t\tif len(ips) == 0 { // SRV/TXT, lookup failed\n\t\t\t\treturn errors.New(\"failed to get IP address for domain \", domain)\n\t\t\t}\n\t\t\tif addr := net.IPAddress(ips[dice.Roll(len(ips))]); addr != nil {\n\t\t\t\tdialDest.Address = addr\n\t\t\t\terrors.LogInfo(ctx, \"dialing to \", dialDest)\n\t\t\t}\n\t\t}\n\t\tif rule := h.matchFinalRule(dialDest.Network, dialDest.Address, dialDest.Port, defaultRule); rule != nil && rule.action == RuleAction_Block {\n\t\t\tblockedDest = &dialDest\n\t\t\tblockedRule = rule\n\t\t\treturn nil\n\t\t}\n","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/freedom/freedom.go#L304-L340","documentation":"With domainStrategy UseIP/UseIPv4/UseIPv6, freedom resolves the destination domain itself before dialing. On the first resolve it queries the system resolver for A records (if IPv4 routes exist) then AAAA (if IPv6 routes exist); if both come back empty, it fails with this error naming the domain. The lookup uses Go's net.DefaultResolver, so it follows /etc/resolv.conf and the OS.","triggerScenarios":"destination.domainStrategy set to UseIP/UseIPv4/UseIPv6 plus a domain that returns no A/AAAA records (NXDOMAIN, DNS-only-HTTPS records), or a broken system resolver on the Xray host. Also triggered when CheckRoutes() reports no usable IPv4/IPv6 route so both lookups are skipped.","commonSituations":"Host with no DNS configured (containers with empty resolv.conf), IPv6 disabled at the OS but strategy forcing ip6, typo'd domain, or a resolver that filters records. Because the error is swallowed into `ips, _`, the real DNS error is invisible — check with `dig @<resolver> <domain> A` on the host.","solutions":["From the Xray host, run `dig <domain> A +short` and `dig <domain> AAAA +short` to confirm the system resolver returns records","Fix /etc/resolv.conf or the container's DNS settings so net.DefaultResolver works","If DNS is intentionally handled elsewhere, set domainStrategy to \"AsIs\" so freedom dials by name","Verify the host actually has IPv4/IPv6 routes (CheckRoutes gates the lookups)"],"exampleFix":"// before\n\"settings\": { \"domainStrategy\": \"UseIP\" }\n// after (let remote/proxy resolve, or fix host DNS first)\n\"settings\": { \"domainStrategy\": \"AsIs\" }","handlingStrategy":"validation","validationCode":"```go\nif ips, err := net.DefaultResolver.LookupIP(ctx, \"ip\", domain); err != nil || len(ips) == 0 {\n    // skip UseIP strategy or fail fast with a clear reason\n}\n```","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Health-check host DNS before enabling UseIP/UseIPv4/UseIPv6","Prefer AsIs when a remote resolver is authoritative","Confirm IPv4/IPv6 routes exist (CheckRoutes gates lookups)"],"tags":["freedom","dns","domain-strategy","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}