{"record":{"id":"14e2b313b5162dc9","repo":"valyala/fasthttp","slug":"couldn-t-find-dns-entries-for-the-given-domain-tr","errorCode":null,"errorMessage":"couldn't find dns entries for the given domain: try using dual-stack dialing","messagePattern":"couldn't find dns entries for the given domain: try using dual-stack dialing","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tcpdialer.go","lineNumber":552,"sourceCode":"\taddrs := make([]net.TCPAddr, 0, n)\n\tfor i := range n {\n\t\tip := ipaddrs[i]\n\t\tif !dualStack && ip.IP.To4() == nil {\n\t\t\tcontinue\n\t\t}\n\t\taddrs = append(addrs, net.TCPAddr{\n\t\t\tIP:   ip.IP,\n\t\t\tPort: port,\n\t\t\tZone: ip.Zone,\n\t\t})\n\t}\n\tif len(addrs) == 0 {\n\t\treturn nil, errNoDNSEntries\n\t}\n\treturn addrs, nil\n}\n\nvar errNoDNSEntries = errors.New(\"couldn't find dns entries for the given domain: try using dual-stack dialing\")\n","sourceCodeStart":534,"sourceCodeEnd":553,"githubUrl":"https://github.com/valyala/fasthttp/blob/c96f600972c6f4a7a30d664257b340ebe9d60124/tcpdialer.go#L534-L553","documentation":"errNoDNSEntries is returned by resolveTCPAddrs when DNS resolution for the dial target completes but yields an empty address list. The library appends the hint 'try using dual-stack dialing' because the most common cause is dialing with a network string (e.g. tcp4/tcp6) that excludes the address family the domain actually resolves to (e.g. an IPv6-only domain resolved while forcing tcp4).","triggerScenarios":"Calling a TCP dialer with a network of 'tcp4' or 'tcp6' for a domain whose DNS records only contain the other address family, or a domain with no A/AAAA records at all; resolveTCPAddrs then produces len(addrs)==0 and returns errNoDNSEntries.","commonSituations":"Hardcoding network:'tcp4' for services that are IPv6-only; a domain whose AAAA/A records were just removed; split-horizon or filtered DNS returning no records inside containers/VPNs; typo'd hostname with no records.","solutions":["Change the dial network to 'tcp' (dual-stack) so both A and AAAA results are accepted","Verify DNS records exist: run `dig A <host>` and `dig AAAA <host>` and fix DNS if empty","Fix the hostname typo or use the correct domain","If you must pin tcp4/tcp6, confirm the domain has records of that family before dialing"],"exampleFix":"// before\nconn, err := dialer.Dial(\"tcp4\", \"ipv6-only.example.com:443\")\n// after\nconn, err := dialer.Dial(\"tcp\", \"ipv6-only.example.com:443\")","handlingStrategy":"validation","validationCode":"func canDial(host, network string) error {\n  ips, err := net.LookupIP(host)\n  if err != nil { return err }\n  for _, ip := range ips {\n    if network == \"tcp4\" && ip.To4() != nil { return nil }\n    if network == \"tcp6\" && ip.To4() == nil { return nil }\n    if network == \"tcp\" { return nil }\n  }\n  return fmt.Errorf(\"host %s has no addresses for network %s\", host, network)\n}","typeGuard":"func isDualStackSafe(network string) bool { return network == \"tcp\" }","tryCatchPattern":"addrs, err := dialer.Dial(network, addr)\nif err != nil {\n  if strings.Contains(err.Error(), \"couldn't find dns entries\") {\n    addrs, err = dialer.Dial(\"tcp\", addr) // retry dual-stack\n  }\n}","preventionTips":["Always prefer network \"tcp\" (dual-stack) unless you have a hard requirement","Pre-flight LookupIP and filter by family before choosing tcp4/tcp6","Monitor DNS zones so A/AAAA record removals are caught","Log the network string and resolved addresses on dial failure"],"tags":["network","dns","tcp","ipv6"],"backgroundTag":"dns-resolution-empty","analyzedSha":"c96f600972c6f4a7a30d664257b340ebe9d60124","analyzedAt":"2026-08-31T22:48:28.265Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}