valyala/fasthttp · error
couldn't find dns entries for the given domain: try using du
Error message
couldn't find dns entries for the given domain: try using dual-stack dialing
What it means
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).
Source
Thrown at tcpdialer.go:552
addrs := make([]net.TCPAddr, 0, n)
for i := range n {
ip := ipaddrs[i]
if !dualStack && ip.IP.To4() == nil {
continue
}
addrs = append(addrs, net.TCPAddr{
IP: ip.IP,
Port: port,
Zone: ip.Zone,
})
}
if len(addrs) == 0 {
return nil, errNoDNSEntries
}
return addrs, nil
}
var errNoDNSEntries = errors.New("couldn't find dns entries for the given domain: try using dual-stack dialing")
View on GitHub (pinned to c96f600972)
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
Example fix
// before
conn, err := dialer.Dial("tcp4", "ipv6-only.example.com:443")
// after
conn, err := dialer.Dial("tcp", "ipv6-only.example.com:443") Defensive patterns
Strategy: validation
Validate before calling
func canDial(host, network string) error {
ips, err := net.LookupIP(host)
if err != nil { return err }
for _, ip := range ips {
if network == "tcp4" && ip.To4() != nil { return nil }
if network == "tcp6" && ip.To4() == nil { return nil }
if network == "tcp" { return nil }
}
return fmt.Errorf("host %s has no addresses for network %s", host, network)
} Type guard
func isDualStackSafe(network string) bool { return network == "tcp" } Try / catch
addrs, err := dialer.Dial(network, addr)
if err != nil {
if strings.Contains(err.Error(), "couldn't find dns entries") {
addrs, err = dialer.Dial("tcp", addr) // retry dual-stack
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- fasthttp: dialing to the given tcp address timed out
- only tcp, tcp4, or tcp6 is supported
- value is negative, cannot convert to uint32
- value exceeds uint32 max value
- value is negative, cannot convert to uintptr
AI-assisted analysis of valyala/fasthttp@c96f600972 (2026-08-31).
Data as JSON: /api/errors/14e2b313b5162dc9.
Report an issue: GitHub.