thanos-io/thanos · error

invalid SRV response record

Error message

invalid SRV response record %s

What it means

The SRV answer contained a record type the resolver does not handle: only *dns.SRV and *dns.CNAME are accepted, and anything else (A, TXT, SOA, etc.) aborts the lookup with this error naming the offending record. It indicates the DNS server returned a malformed or unexpected answer for an SRV query.

Solutions

  1. Inspect the record named in the error with dig SRV <name> +noall +answer to see what the server actually returns
  2. Fix the DNS zone: create a proper SRV record at _service._proto.name instead of A/TXT records
  3. If a proxy/firewall alters DNS replies, bypass or fix it
  4. Point the resolver at a DNS server that correctly serves the SRV zone
Defensive patterns

Strategy: try-catch

Validate before calling

// check the record type actually served
out, _ := exec.Command("dig", "+short", "SRV", name).Output()
if !strings.Contains(string(out), "SRV") { /* wrong record type registered */ }

Try / catch

if err != nil && strings.Contains(err.Error(), "invalid SRV response record") {
    return fmt.Errorf("DNS server misbehaving for %s: %w", name, err) // don't retry blindly
}

Prevention

When it happens

Trigger: Iterating msg.Answer of an SRV response and hitting the default case — the server answered with records other than SRV/CNAME, e.g. an A record set for what should be an SRV name.

Common situations: Misconfigured DNS server or load balancer answering A records for SRV queries; middleboxes/DPI rewriting DNS answers; wrong record type registered for the _service._proto name.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/0d49d92339d99dc5. Report an issue: GitHub.

Appendix: source

Thrown at pkg/discovery/dns/miekgdns/resolver.go:60

	for _, record := range response.Answer {
		switch addr := record.(type) {
		case *dns.SRV:
			addrs = append(addrs, &net.SRV{
				Weight:   addr.Weight,
				Target:   addr.Target,
				Priority: addr.Priority,
				Port:     addr.Port,
			})
		case *dns.CNAME:
			// Recursively resolve it.
			_, resp, err := r.lookupSRV("", "", addr.Target, currIteration+1, maxIterations)
			if err != nil {
				return "", nil, errors.Wrapf(err, "recursively resolve %s", addr.Target)
			}
			addrs = append(addrs, resp...)
		default:
			return "", nil, errors.Errorf("invalid SRV response record %s", record)
		}
	}

	return "", addrs, nil
}

func (r *Resolver) LookupIPAddr(_ context.Context, host string) ([]net.IPAddr, error) {
	return r.lookupIPAddr(host, 1, 8)
}

func (r *Resolver) LookupIPAddrByNetwork(ctx context.Context, network, host string) ([]net.IPAddr, error) {
	var qtype dns.Type
	switch network {
	case "ip6":
		qtype = dns.Type(dns.TypeAAAA)
	case "ip4":
		qtype = dns.Type(dns.TypeA)
	default:

View on GitHub (pinned to 35b8b99117)