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
- Inspect the record named in the error with dig SRV <name> +noall +answer to see what the server actually returns
- Fix the DNS zone: create a proper SRV record at _service._proto.name instead of A/TXT records
- If a proxy/firewall alters DNS replies, bypass or fix it
- 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
- Register correct SRV records (_service._proto.name SRV ...) rather than A/TXT at those names
- Test with dig SRV before wiring up discovery
- Bypass or reconfigure middleboxes that rewrite DNS answers
- Use a reputable DNS server for zones serving SRV records
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
- maximum number of recursive iterations reached
- recursively resolve
- invalid A, AAAA or CNAME response record
- lookup SRV records
- no such host
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)