txthinking/brook · error

Can not resolve

Error message

Can not resolve 

What it means

The DialWithDNS IP method queries the configured DNS (or DoH) client for the domain's A record; the resolver returned a nil IP without a transport error. The plugin then surfaces "Can not resolve <domain>" to indicate the DNS answer contained no usable IPv4 address.

Source

Thrown at plugins/dialwithdns/dialwithdns.go:64

func (p *DialWithDNS) IP(domain string) (net.IP, error) {
	if p.Prefer == "A" {
		if p.DNSClient != nil {
			ip, err := p.DNSClient.A(domain)
			if err != nil {
				return nil, err
			}
			if ip != nil {
				return ip, nil
			}
			ip, err = p.DNSClient.AAAA(domain)
			if err != nil {
				return nil, err
			}
			if ip != nil {
				return ip, nil
			}
			return nil, errors.New("Can not resolve " + domain)
		}
		if p.DOHClient != nil {
			ip, err := p.DOHClient.A(domain)
			if err != nil {
				return nil, err
			}
			if ip != nil {
				return ip, nil
			}
			ip, err = p.DOHClient.AAAA(domain)
			if err != nil {
				return nil, err
			}
			if ip != nil {
				return ip, nil
			}
			return nil, errors.New("Can not resolve " + domain)
		}

View on GitHub (pinned to 5cd13ef3b1)

Solutions

  1. Switch prefer to "AAAA" if the target domain is IPv6-only.
  2. Point the DNS/DoH server to a reliable public resolver (e.g., https://1.1.1.1/dns-query or 8.8.8.8).
  3. Verify the domain actually has an A record with dig/nslookup against the same resolver.
  4. Check network egress: corporate filters or the GFW-style interference may be blanking DNS answers; use DoH instead of plain DNS.

Example fix

// before
p, err := NewDialWithDNS("10.0.0.1", "A") // office DNS returns empty answers
// after
p, err := NewDialWithDNS("https://1.1.1.1/dns-query", "AAAA") // IPv6-only domain, DoH resolver
Defensive patterns

Strategy: fallback

Validate before calling

if addrs, err := net.LookupHost(domain); err != nil || len(addrs) == 0 {
    log.Printf("%s has no usable records, adjusting prefer", domain)
}

Try / catch

ip, err := plugin.IP(network, domain)
if err != nil && strings.Contains(err.Error(), "Can not resolve") {
    // retry with the other record type
    return fallbackDialer.Dial(network, hostPort)
}

Prevention

When it happens

Trigger: Calling DialWithDNS.Dial/DialContext for a domain whose A lookup succeeds at the transport level but returns no A record (nil ip); a DoH server answering with an empty answer section.

Common situations: Resolving IPv6-only hostnames while prefer="A"; DNS servers (or blocked DoH endpoints) returning empty/filtered answers; NXDOMAIN-like behavior surfaced as empty result rather than error; captive networks stripping answers.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of txthinking/brook@5cd13ef3b1 (2026-09-06). Data as JSON: /api/errors/b8c7870df7d61567. Report an issue: GitHub.