coredns/coredns · warning
no nameservers found
Error message
no nameservers found
What it means
parse.ErrNoNameservers is a sentinel error from CoreDNS's parse package, returned by HostPortOrFile (and classifyToAddrs) when resolv.conf-style input yields zero usable nameservers. The forward/resolve code explicitly checks for it with errors.Is and skips the source instead of failing, because an empty nameserver list is often benign (e.g. an empty file).
Source
Thrown at plugin/pkg/parse/host.go:16
package parse
import (
"errors"
"fmt"
"net"
"os"
"strings"
"github.com/coredns/coredns/plugin/pkg/transport"
"github.com/miekg/dns"
)
// ErrNoNameservers is returned by HostPortOrFile if no servers can be parsed.
var ErrNoNameservers = errors.New("no nameservers found")
// Strips the zone, but preserves any port that comes after the zone
func stripZone(host string) string {
if strings.Contains(host, "%") {
lastPercent := strings.LastIndex(host, "%")
newHost := host[:lastPercent]
return newHost
}
return host
}
// HostPortOrFile parses the strings in s, each string can either be a
// address, [scheme://]address:port or a filename. The address part is checked
// and in case of filename a resolv.conf like file is (assumed) and parsed and
// the nameservers found are returned.
func HostPortOrFile(s ...string) ([]string, error) {
var servers []string
for _, h := range s {View on GitHub (pinned to 558c9757a9)
Solutions
- Check the resolv.conf the forward plugin reads and add valid `nameserver` entries.
- If /etc/resolv.conf is empty, point the forward directive at an explicit upstream list, e.g. `forward . 8.8.8.8 8.8.4.4`.
- For containers, configure the runtime's DNS settings (docker --dns, kubelet resolvConf) so resolv.conf is populated.
- Verify nameserver lines are not commented out or misspelled (e.g. `name_server`).
Example fix
// Corefile // before forward . /etc/resolv.conf # empty file -> no servers // after forward . 8.8.8.8 1.1.1.1
Defensive patterns
Strategy: fallback
Validate before calling
if st, err := os.Stat(resolvConf); err != nil || st.Size() == 0 {
return errors.New("resolv.conf missing or empty")
} Try / catch
servers, parseErr := parse.HostPortOrFile(path)
if errors.Is(parseErr, parse.ErrNoNameservers) {
continue // or fall back to static upstreams
} Prevention
- Ensure resolv.conf has at least one nameserver line
- Prefer explicit upstream IPs in the Corefile
- Configure container runtime DNS properly
When it happens
Trigger: HostPortOrFile parses a resolv.conf (or file/direct config) that contains no valid nameserver entries, so len(servers) == 0 and the sentinel is returned; plugin/forward/resolve.go then skips that source and tries the next.
Common situations: Forward plugin configured with `forward . /etc/resolv.conf` where /etc/resolv.conf is empty or has all nameserver lines stripped (common in minimal containers or systemd-resolved setups); malformed resolv.conf where nameserver lines are commented or misspelled; Kubernetes pod networking edge cases leaving an empty file.
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
- key %s (keyid: %d) can not sign any of the zones
- not an IP address, file, or valid domain: %q
- %s is not a valid rcode
- unknown/unsupported flag=%s
- setting up rule: invalid selector=%s should be query or resp
AI-assisted analysis of coredns/coredns@558c9757a9 (2026-09-06).
Data as JSON: /api/errors/023bbea7f2b6ebf6.
Report an issue: GitHub.