{"record":{"id":"41c69ba1e76a5b4d","repo":"XTLS/Xray-core","slug":"failed-to-build-nameserver","errorCode":null,"errorMessage":"failed to build nameserver","messagePattern":"failed to build nameserver","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/dns.go","lineNumber":357,"sourceCode":"\t\twriteList(\"expected\", nsc.ExpectedIPs)\n\t\twriteList(\"expect\", nsc.ExpectIPs)\n\t\twriteList(\"unexpected\", nsc.UnexpectedIPs)\n\n\t\tkey := sb.String()\n\n\t\tif id, ok := policyMap[key]; ok {\n\t\t\treturn id\n\t\t}\n\t\tid := nextPolicyID\n\t\tnextPolicyID++\n\t\tpolicyMap[key] = id\n\t\treturn id\n\t}\n\n\tfor _, server := range c.Servers {\n\t\tns, err := server.Build()\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"failed to build nameserver\").Base(err)\n\t\t}\n\t\tns.PolicyID = buildPolicyID(server)\n\t\tconfig.NameServer = append(config.NameServer, ns)\n\t}\n\n\tif c.Hosts != nil {\n\t\tstaticHosts, err := c.Hosts.Build()\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"failed to build hosts\").Base(err)\n\t\t}\n\t\tconfig.StaticHosts = append(config.StaticHosts, staticHosts...)\n\t}\n\tif c.UseSystemHosts {\n\t\tsystemHosts, err := readSystemHosts()\n\t\tif err != nil {\n\t\t\treturn nil, errors.New(\"failed to read system hosts\").Base(err)\n\t\t}\n\t\tconfig.StaticHosts = append(config.StaticHosts, systemHosts...)","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/dns.go#L339-L375","documentation":"Wrapper error from dns Config Build in infra/conf/dns.go: one of the dns.servers entries failed NameServerConfig.Build (address missing, bad clientIp, invalid expected-IP rules, geodata parse failure). The underlying error is chained with .Base(err), so the real cause is one level down in the error chain.","triggerScenarios":"Any per-server Build failure inside the servers loop: errors 252 (no address) or 253 (clientIp not IP) are the typical bases; invalid geodata rule strings in 'domains'/'expectedIPs' also land here.","commonSituations":"One bad entry in an otherwise long servers array; after upgrading Xray the geodata rule syntax changed and an old entry no longer parses.","solutions":["Inspect the chained base error to identify which server entry and which check failed","Fix that entry per the underlying error (add address, fix clientIp, correct geodata rules)","Bisect the servers array by commenting out entries to locate the offender quickly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for i, server := range dnsCfg.Servers {\n    if _, err := server.Build(); err != nil {\n        return fmt.Errorf(\"dns.servers[%d] invalid: %w\", i, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := dnsConf.Build(); err != nil {\n    var baseErr = err\n    for errors.Unwrap(baseErr) != nil {\n        baseErr = errors.Unwrap(baseErr) // descend to the real per-server cause\n    }\n    return fmt.Errorf(\"DNS build failed at servers entry, root cause: %v\", baseErr)\n}","preventionTips":["Unwrap the .Base chain to find the real failing entry","Build each server entry individually during config generation to localize errors"],"tags":["config","dns","wrapper-error","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}