{"record":{"id":"c7a42bbab2d5ea36","repo":"ginuerzh/gost","slug":"resolver-domain-s-does-not-exists","errorCode":null,"errorMessage":"resolver: domain %s does not exists","messagePattern":"resolver: domain (.+?) does not exists","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chain.go","lineNumber":158,"sourceCode":"}\n\nfunc (c *Chain) dialWithOptions(ctx context.Context, network, address string, options *ChainOptions) (net.Conn, error) {\n\tif options == nil {\n\t\toptions = &ChainOptions{}\n\t}\n\tif c == nil {\n\t\tc = &Chain{}\n\t}\n\troute, err := c.selectRouteFor(address)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tipAddr := address\n\tif address != \"\" {\n\t\tipAddr = c.resolve(address, options.Resolver, options.Hosts)\n\t\tif ipAddr == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"resolver: domain %s does not exists\", address)\n\t\t}\n\t}\n\n\ttimeout := options.Timeout\n\tif timeout <= 0 {\n\t\ttimeout = DialTimeout\n\t}\n\n\tvar controlFunction func(_ string, _ string, c syscall.RawConn) error = nil\n\tif c.Mark > 0 {\n\t\tcontrolFunction = func(_, _ string, cc syscall.RawConn) error {\n\t\t\treturn cc.Control(func(fd uintptr) {\n\t\t\t\tex := setSocketMark(int(fd), c.Mark)\n\t\t\t\tif ex != nil {\n\t\t\t\t\tlog.Logf(\"net dialer set mark %d error: %s\", c.Mark, ex)\n\t\t\t\t} else {\n\t\t\t\t\t// log.Logf(\"net dialer set mark %d success\", options.Mark)\n\t\t\t\t}","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/chain.go#L140-L176","documentation":"chain.DialWithOptions fails when the configured resolver (and hosts table) cannot resolve the target hostname: c.resolve returns an empty string and the dialer aborts with 'resolver: domain %s does not exists'. It means DNS resolution of the dial address failed at the resolver level, before any network connection was attempted.","triggerScenarios":"Dialing a hostname whose domain does not exist (NXDOMAIN), a resolver that cannot answer (wrong DNS server, blocked UDP 53), or Hosts/Resolver options filtering out the name so resolve() returns empty.","commonSituations":"Typo in the target hostname in the gost config; custom -resolver/-hosts settings pointing to an unreachable or incorrect DNS server; internal-only domains queried against public DNS; transient DNS outages.","solutions":["Verify the hostname is correct and resolvable: run `dig <domain>` or `nslookup <domain>` against the configured resolver.","Fix the resolver configuration (correct DNS server address/port, or remove the custom resolver to use system DNS).","Add the hostname to the Hosts table (-hosts file or Resolver hosts) as a workaround for NXDOMAIN or internal domains.","If resolution is intermittently failing, retry or add a secondary resolver for redundancy."],"exampleFix":"// before\ndialer.DialWithOptions(ctx, \"api.mycompany.internal:443\", ...) // fails: resolver can't resolve\n// after\nresolver := net.Resolver{PreferGo: true, Dial: ...} // point at internal DNS\n// or map it explicitly in hosts: 10.0.0.5 api.mycompany.internal\n","handlingStrategy":"validation","validationCode":"ips, err := net.LookupHost(\"api.example.com\")\nif err != nil || len(ips) == 0 {\n    return fmt.Errorf(\"hostname not resolvable via configured resolver: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"conn, err := d.DialContext(ctx, network, addr)\nif err != nil {\n    if strings.Contains(err.Error(), \"does not exists\") {\n        // retry with fallback resolver or check hosts table\n    }\n    return err\n}","preventionTips":["Verify hostnames with dig/nslookup against the exact resolver you configured.","Keep a hosts file entry for internal-only domains.","Configure at least two resolvers for redundancy.","Watch for NXDOMAIN caused by typos or search-domain issues in containerized environments."],"tags":["dns","resolver","nxdomain","network","dial"],"backgroundTag":"dns-resolution-failed","analyzedSha":"a33fdbf4c98034f4bfeeaea9868909822b9c526d","analyzedAt":"2026-09-02T22:15:54.506Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}