SERVFAIL from Consul’s DNS interface on port 8600 means service discovery is broken for every application resolving names through it. Applications see connection refused, timeouts, and cascading failovers. The symptom is broad, but the root cause lives along one of four layers: the downstream resolver (if present), the Consul agent’s built-in DNS server, the agent-to-server RPC channel, or the server’s catalog state.

NXDOMAIN is a related but distinct signal. SERVFAIL means the resolver could not complete the query: server overload, timeout, unreachable upstream, or internal error. NXDOMAIN means the query completed but the name does not exist in the catalog. Both break discovery, but they point to different layers. Conflating them during an incident wastes time.

The diagnostic path matters because Consul DNS is frequently chained behind dnsmasq, systemd-resolved, or corporate DNS forwarders. These layers cache both successes and failures. A SERVFAIL that lasts 30 seconds at the Consul agent can persist for minutes at the downstream resolver, which may keep serving the cached failure long after Consul itself has recovered.

What this means

Consul’s DNS server listens on UDP and TCP port 8600 by default and answers queries for the consul. domain. Each query for <service>.service.consul triggers an internal catalog lookup that flows from the agent to a server over RPC, then into the replicated state store. If any link fails or is too slow, the agent returns SERVFAIL or serves a stale cached result.

The four failure layers and their symptoms:

  1. Downstream resolver (dnsmasq, systemd-resolved, corporate DNS): caches responses, including failures. Amplifies a brief Consul blip into a sustained outage.
  2. Consul agent DNS server: serves queries from local cache or forwards to servers. If it cannot reach any server, returns SERVFAIL or serves stale data depending on configuration.
  3. Agent-to-server RPC: the channel for catalog lookups. If blocked, timed out, or rate-limited, DNS queries fail at the agent.
  4. Server catalog and state store: the authoritative source. If the catalog is inconsistent, ACLs deny the query, or the scan is too slow due to cardinality, the server returns empty results or times out.
flowchart TD
    App[Application query] --> Resolver[Downstream resolver
dnsmasq / systemd-resolved] Resolver --> Agent[Consul agent DNS :8600] Agent --> Server[Consul server RPC] Server --> Catalog[Catalog / state store] Agent -.->|server unreachable| ServfailA[SERVFAIL or stale] Server -.->|overloaded or slow| ServfailB[SERVFAIL or timeout] Catalog -.->|empty result or ACL deny| Nxdomain[NXDOMAIN] Resolver -.->|caches SERVFAIL| CachedFail[persistent failure]

The key first distinction: if dig directly against 127.0.0.1 -p 8600 succeeds but the application still fails, the problem is in the downstream resolver or its caching layer, not in Consul itself.

Common causes

CauseWhat it looks likeFirst thing to check
Agent cannot reach any serverSERVFAIL or stale results from direct dig queries; consul.dns.stale_queries counter risingconsul info on the agent; check consul.client.rpc.failed
Server cluster overloadedHigh DNS latency across all services; consul.raft.commitTime elevated; RPC p99 climbingCheck leader health and disk I/O latency on servers
Catalog inconsistencyNXDOMAIN for a service registered locally on the agent; anti-entropy sync failingCompare consul catalog services output with local agent registrations
Large service cardinalityDNS latency proportional to service instance count; slow catalog scan timeoutsCheck total service and check counts in the catalog
ACL denialNXDOMAIN for .service.consul queries when ACLs are enabled; works with management tokenCheck agent token permissions and ACL resolution latency
Prepared query complexityLatency spikes on prepared query lookups; rate-limit interactionsTest the prepared query directly via HTTP API
Downstream resolver caching failuresApplication fails but direct dig to :8600 works; SERVFAIL persists after Consul recoversFlush resolver caches; check resolver TTL config
Recursor failureSERVFAIL on queries that trigger recursion; recursor unreachable or returning SERVFAILCheck recursor_timeout config and recursor reachability

Quick checks

Run these on the node where the application is failing. All are read-only and safe.

# Direct DNS query to the Consul agent, bypassing downstream resolvers
dig @127.0.0.1 -p 8600 myservice.service.consul SRV +stats +time=2 +tries=1

# Check if the agent knows about any servers
consul info | grep -A5 "known_servers"

# Verify leader exists and is reachable
curl -s http://127.0.0.1:8500/v1/status/leader

# Check DNS-specific telemetry counters
curl -s http://127.0.0.1:8500/v1/agent/metrics | grep -E "dns\.|stale_queries"

# Check if the service exists in the catalog at all
curl -s "http://127.0.0.1:8500/v1/catalog/service/myservice" | jq length

# Check healthy instances specifically
curl -s "http://127.0.0.1:8500/v1/health/service/myservice?passing=true" | jq length

# Verify agent-to-server RPC health
curl -s http://127.0.0.1:8500/v1/agent/metrics | grep "client.rpc"

# If using dnsmasq, check if it is forwarding correctly
dig @127.0.0.1 -p 53 myservice.service.consul SRV +time=2

# If using systemd-resolved, check its cache and forwarding
resolvectl statistics
resolvectl query myservice.service.consul

If the direct query to port 8600 succeeds but the downstream resolver query fails, the problem is in the caching or forwarding layer. If the direct query fails, the problem is in Consul.

How to diagnose it

  1. Bypass downstream resolvers first. Always start with dig @127.0.0.1 -p 8600. This isolates Consul from dnsmasq, systemd-resolved, and corporate DNS infrastructure. If this works, skip to step 7.

  2. Check the response code. SERVFAIL (rcode 2) means the query could not complete. NXDOMAIN (rcode 3) means the name does not exist. The status: line in dig output shows the rcode.

  3. Verify server reachability from the agent. Run consul info and check known_servers. If it shows zero or the agent cannot reach the leader, the agent returns SERVFAIL or serves stale results. Check consul.client.rpc.failed for sustained non-zero rates.

  4. Check leader existence and Raft health. Query curl http://127.0.0.1:8500/v1/status/leader. An empty string means no leader, which means no catalog lookups can complete. Check consul.raft.commitTime for sustained elevation above 100ms.

  5. Verify the service exists in the catalog. Query curl http://127.0.0.1:8500/v1/catalog/service/<name>. If the catalog returns empty but the service is registered locally on the agent, anti-entropy sync is failing. Check anti-entropy metrics for failure rates.

  6. Check ACL resolution if ACLs are enabled. DNS queries for <service>.service.consul require the agent’s token to have service:read permission on the target service. A token without permission produces NXDOMAIN, not an explicit denial. Test with a management token to confirm.

  7. If direct Consul DNS works, test the downstream resolver. Query through dnsmasq or systemd-resolved. If it returns SERVFAIL while direct Consul DNS works, the resolver is caching a stale failure or has a forwarding misconfiguration.

  8. Check for recursor loops. If Consul has recursors configured that point back to a resolver that forwards to Consul, a DS consul. query can loop. dnsmasq’s concurrent pending query limit fills up, causing SERVFAIL for all requests.

  9. Check consul.dns.stale_queries. This counter tracks queries served stale by more than 5 seconds. A rising value means the agent is serving cached results because it cannot reach servers fast enough.

Metrics and signals to monitor

SignalWhy it mattersWarning sign
consul.dns.domain_query latencyDirect measure of DNS response time from the agentp99 above 100ms for fresh lookups, or trending upward
consul.dns.stale_queries counterTracks queries served from stale cache because servers were unreachableAny sustained non-zero rate
consul.raft.commitTimeWrite pipeline health; DNS queries for consistent reads depend on RaftSustained above 100ms; approaching heartbeat timeout risks leader loss
consul.client.rpc.failedAgent-to-server connectivity; failed RPC means DNS cannot reach the catalogAny sustained non-zero rate on client agents
consul.rpc.request latencyServer-side RPC processing time; high latency slows all DNS lookupsp99 above 1s
Total service and check countsCatalog cardinality; large catalogs slow DNS scansGrowth without corresponding service growth
ACL token resolution latencyACL overhead per DNS query when ACLs are enabledAbove 10ms sustained
Disk I/O await on server Raft volumeLeading indicator for Raft commit time degradationSustained above 10ms

Fixes

Agent cannot reach any server

The most common cause of persistent SERVFAIL. The agent is alive and serving DNS, but has no server to query.

  • Verify network connectivity on port 8300 (RPC) between the agent and servers. A firewall change that blocks 8300 while leaving 8301 (gossip) open produces exactly this symptom: the agent appears healthy in gossip but cannot push or pull catalog state.
  • Check server file descriptor usage. If servers are at their FD limit, they reject new RPC connections. The fix is raising the ulimit, not restarting Consul.
  • If allow_stale is true (the default since Consul 0.7), the agent serves cached results instead of SERVFAIL when servers are unreachable. This masks the failure temporarily but produces increasingly stale data. Whether that is acceptable depends on how stale is tolerable for your consumers.

Server cluster overloaded

DNS queries require catalog lookups on servers. If the server cluster is saturated, DNS latency spikes and eventually times out.

  • Check consul.raft.commitTime and disk I/O latency. Slow disks are the most common cause of Raft degradation.
  • Check consul.runtime.num_goroutines and file descriptor usage for resource exhaustion.
  • If the overload is from catalog churn (health check flapping, registration storms), the DNS symptom is secondary. Address the churn source first. See Consul registration storm.

Catalog inconsistency producing NXDOMAIN

The service is registered locally on the agent but not visible in the catalog. Anti-entropy sync is failing.

  • Check anti-entropy metrics for failure rates.
  • Verify the agent can reach servers on port 8300.
  • If necessary, force a sync by restarting the agent. This is disruptive: the agent re-registers all services, causing a brief registration burst that adds load to the server cluster.

ACL denial producing NXDOMAIN

When ACLs are enabled, DNS queries require the agent’s token to have service:read permission on the target service. A token without permission returns NXDOMAIN, not an explicit error.

  • Verify the agent token has a matching service_prefix or service ACL rule granting read permission.
  • Check ACL token resolution latency. High latency on every DNS query indicates ACL cache misses or an undersized token cache.

Downstream resolver caching SERVFAIL

systemd-resolved caches SERVFAIL responses for long periods. dnsmasq can enter a forwarding loop with Consul recursors.

  • Flush caches: resolvectl flush-caches for systemd-resolved; restart dnsmasq if it is stuck in a loop.
  • On systemd v246+, ensure the DNS config includes the port explicitly: DNS=127.0.0.1:8600.
  • Consider setting use_cache and appropriate TTLs on the Consul agent to control caching behavior at the source.

Recursor SERVFAIL

If Consul has recursors configured and a recursor returns SERVFAIL, older Consul versions do not fail over to the next recursor in the list.

  • Check recursor_timeout (default 2s). If recursors are slow, queries time out and return SERVFAIL.
  • Use recursor_strategy: random to distribute load across recursors instead of always hitting the first one sequentially.

Prepared query complexity

Prepared queries can add latency and interact with rate limits when the result set is large.

  • Test the prepared query directly: curl -s "http://127.0.0.1:8500/v1/query/<name>/execute".
  • If the query is slow, check the number of matching service instances. Large result sets increase execution time.

Prevention

  • Monitor consul.dns.stale_queries and DNS latency. These are the earliest indicators that DNS resolution is degrading, before applications start failing.
  • Monitor agent-to-server RPC health on every client agent. Sustained consul.client.rpc.failed is the leading indicator for catalog staleness, which manifests as NXDOMAIN or SERVFAIL.
  • Track catalog size growth. Large catalogs slow DNS scans. Monitor total service instances and health check counts as capacity signals.
  • Test DNS resolution as part of health checks. A synthetic query against a known service catches DNS degradation before real applications hit it.
  • Document your resolver chain. If you run dnsmasq or systemd-resolved in front of Consul, ensure the team knows how to flush caches and diagnose forwarding loops during incidents.
  • Verify ACL token permissions after policy changes. A token that loses read permission on a service produces NXDOMAIN silently with no error log.

How Netdata helps

  • DNS latency and stale query tracking at per-second resolution. Netdata collects consul.dns.domain_query timers and consul.dns.stale_queries, making DNS degradation visible within seconds rather than relying on longer scrape intervals.
  • Correlating DNS failures with Raft and RPC health. When DNS latency spikes, overlay consul.raft.commitTime, consul.client.rpc.failed, and RPC latency together to distinguish “agent cannot reach server” from “server is overloaded” from “catalog is stale.”
  • Agent-to-server RPC failure detection. Netdata tracks consul.client.rpc.failed on every agent, surfacing the pattern where agents are alive in gossip but cannot push state to the catalog.
  • Disk I/O monitoring on server volumes. Slow disks are the most common root cause of Raft degradation that cascades into DNS failures. Per-disk I/O latency metrics provide early warning before commit times approach the election timeout.