thanos-io/thanos · error

no such host

Error message

no such host

What it means

ErrNoSuchHost is the sentinel error returned when every DNS server queried answers NXDOMAIN for all search-path permutations of the requested name. The Resolver returns it (wrapped via IsNotFound) so callers can distinguish 'name genuinely does not exist' from transient network failures. It is returned both from lookupWithSearchPath (all servers agreed the host doesn't exist) and from the top-level lookup when the SRV/IP result set is empty.

Solutions

  1. Verify the hostname with an independent tool (dig/nslookup) using the same resolv.conf to confirm it truly does not exist
  2. Fix the hostname/service name in your configuration or re-create the missing DNS record/service
  3. Check that your resolv.conf search domains are correct so the short name resolves in the right namespace
  4. In caller code, use errors.Is(err, miekgdns.ErrNoSuchHost) (or the IsNotFound helper) to treat it as a retryable-later 'absent target' rather than a hard failure

Example fix

// before
addrs, err := resolver.LookupSRV(nil, "http", "_tcp", "promethus-backend.svc") // typo
// after
addrs, err := resolver.LookupSRV(nil, "http", "_tcp", "prometheus-backend.svc")
Defensive patterns

Strategy: type-guard

Validate before calling

// check name existence before discovery
out, err := exec.Command("dig", "+short", host).Output()
if err != nil || len(strings.TrimSpace(string(out))) == 0 { /* name missing; fix config first */ }

Type guard

func isNoSuchHost(err error) bool {
    return errors.Is(err, miekgdns.ErrNoSuchHost)
}

Try / catch

if _, err := r.LookupIPAddr(ctx, name); err != nil {
    if isNoSuchHost(err) {
        logger.Debug("target not present yet; skipping", "host", name)
        return // treat as empty, not fatal
    }
    return err
}

Prevention

When it happens

Trigger: Calling LookupSRV, LookupIPAddr or LookupIPAddrByNetwork with a hostname no configured DNS server knows about: every queried server returns RcodeNameError (NXDOMAIN) for every name in the search path, or lookupIPAddrByNetwork finds zero A/AAAA records.

Common situations: Typo in the service/hostname in a config file (e.g. Thanos query/store endpoints); service DNS records removed or service renamed in Kubernetes; querying a name outside the search domains; headless service deleted before discovery runs.

Related errors


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

Appendix: source

Thrown at pkg/discovery/dns/miekgdns/lookup.go:14

// Copyright (c) The Thanos Authors.
// Licensed under the Apache License 2.0.

package miekgdns

import (
	"bytes"
	"net"

	"github.com/miekg/dns"
	"github.com/pkg/errors"
)

var ErrNoSuchHost = errors.New("no such host")

// Copied and slightly adjusted from Prometheus DNS SD:
// https://github.com/prometheus/prometheus/blob/be3c082539d85908ce03b6d280f83343e7c930eb/discovery/dns/dns.go#L212

// lookupWithSearchPath tries to get an answer for various permutations of
// the given name, appending the system-configured search path as necessary.
//
// There are three possible outcomes:
//
//  1. One of the permutations of the given name is recognized as
//     "valid" by the DNS, in which case we consider ourselves "done"
//     and that answer is returned.  Note that, due to the way the DNS
//     handles "name has resource records, but none of the specified type",
//     the answer received may have an empty set of results.
//
//  2. All of the permutations of the given name are responded to by one of
//     the servers in the "nameservers" list with the answer "that name does
//     not exist" (NXDOMAIN).  In that case, it can be considered

View on GitHub (pinned to 35b8b99117)