{"record":{"id":"248c7f6dc98062d3","repo":"XTLS/Xray-core","slug":"nameserver-address-is-not-specified","errorCode":null,"errorMessage":"nameserver address is not specified","messagePattern":"nameserver address is not specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/dns.go","lineNumber":86,"sourceCode":"\t\tc.ExpectedIPs = advanced.ExpectedIPs\n\t\tc.ExpectIPs = advanced.ExpectIPs\n\t\tc.QueryStrategy = advanced.QueryStrategy\n\t\tc.Tag = advanced.Tag\n\t\tc.TimeoutMs = advanced.TimeoutMs\n\t\tc.DisableCache = advanced.DisableCache\n\t\tc.ServeStale = advanced.ServeStale\n\t\tc.ServeExpiredTTL = advanced.ServeExpiredTTL\n\t\tc.FinalQuery = advanced.FinalQuery\n\t\tc.UnexpectedIPs = advanced.UnexpectedIPs\n\t\treturn nil\n\t}\n\n\treturn errors.New(\"failed to parse name server: \", string(data))\n}\n\nfunc (c *NameServerConfig) Build() (*dns.NameServer, error) {\n\tif c.Address == nil {\n\t\treturn nil, errors.New(\"nameserver address is not specified\")\n\t}\n\n\tdomainRules, err := geodata.ParseDomainRules(c.Domains, geodata.Domain_Substr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(c.ExpectedIPs) == 0 {\n\t\tc.ExpectedIPs = c.ExpectIPs\n\t}\n\n\tactPrior := false\n\tvar newExpectedIPs StringList\n\tfor _, s := range c.ExpectedIPs {\n\t\tif s == \"*\" {\n\t\t\tactPrior = true\n\t\t} else {\n\t\t\tnewExpectedIPs = append(newExpectedIPs, s)","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/dns.go#L68-L104","documentation":"Returned by NameServerConfig.Build in infra/conf/dns.go when the nameserver's Address is nil after unmarshaling. Every DNS server entry must yield an address (string form or object form 'address' key); if the advanced object parsed but carried no usable address, Build refuses to continue.","triggerScenarios":"{\"address\": \"\"} style entries that unmarshal but leave Address nil, or programmatic construction of NameServerConfig without setting Address before calling Build. String-form servers always set Address, so this mostly bites object form and API users.","commonSituations":"Third-party config generators emitting {\"domains\":[...]} without an address; runtime code building dns.Config from parsed JSON where an entry was skipped; upstream format changes moving the address key.","solutions":["Add a string address to every dns.servers object entry","If generating configs programmatically, set NameServerConfig.Address (conf.Address) before Build","Validate each servers entry has an 'address' key before feeding the config to Xray"],"exampleFix":"// before\n{\"domains\": [\"geosite:cn\"]}\n\n// after\n{\"address\": \"223.5.5.5\", \"domains\": [\"geosite:cn\"]}","handlingStrategy":"validation","validationCode":"func nameserverHasAddress(entry map[string]any) error {\n    addr, ok := entry[\"address\"]\n    if !ok || addr == nil {\n        return errors.New(\"nameserver entry has no address\")\n    }\n    s, ok := addr.(string)\n    if !ok || s == \"\" {\n        return errors.New(\"nameserver address must be a non-empty string\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := nsc.Build(); err != nil {\n    if strings.Contains(err.Error(), \"nameserver address is not specified\") {\n        return fmt.Errorf(\"dns entry %v: add an 'address' field\", nsc)\n    }\n    return err\n}","preventionTips":["Every servers object needs a non-empty string address","Programmatic users: set conf.NameServerConfig.Address before Build"],"tags":["config","dns","validation","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}