vitessio/vitess · critical

FullyQualifiedHostname: failed to lookup the IP of this mach

Error message

FullyQualifiedHostname: failed to lookup the IP of this machine's hostname (%v): %v

What it means

FullyQualifiedHostname looks up the IP for the machine hostname via net.LookupHost as step 2 of building the FQDN. This error means DNS/host resolution of the local hostname failed, even though the hostname itself was retrieved.

Source

Thrown at go/netutil/netutil.go:73

}

// FullyQualifiedHostname returns the FQDN of the machine.
func FullyQualifiedHostname() (string, error) {
	// The machine hostname (which is also returned by os.Hostname()) may not be
	// set to the FQDN, but only the first part of it e.g. "localhost" instead of
	// "localhost.localdomain".
	// To get the full FQDN, we do the following:

	// 1. Get the machine hostname. Example: localhost
	hostname, err := os.Hostname()
	if err != nil {
		return "", fmt.Errorf("FullyQualifiedHostname: failed to retrieve the hostname of this machine: %v", err)
	}

	// 2. Look up the IP address for that hostname. Example: 127.0.0.1
	ips, err := net.LookupHost(hostname)
	if err != nil {
		return "", fmt.Errorf("FullyQualifiedHostname: failed to lookup the IP of this machine's hostname (%v): %v", hostname, err)
	}
	if len(ips) == 0 {
		return "", fmt.Errorf("FullyQualifiedHostname: lookup of the IP of this machine's hostname (%v) did not return any IP address", hostname)
	}
	// If multiple IPs are returned, we only look at the first one.
	localIP := ips[0]

	// 3. Reverse lookup the IP. Example: localhost.localdomain
	resolvedHostnames, err := net.LookupAddr(localIP)
	if err != nil {
		return "", fmt.Errorf("FullyQualifiedHostname: failed to reverse lookup this machine's local IP (%v): %v", localIP, err)
	}
	if len(resolvedHostnames) == 0 {
		return "", fmt.Errorf("FullyQualifiedHostname: reverse lookup of this machine's local IP (%v) did not return any hostnames", localIP)
	}
	// If multiple hostnames are found, we return only the first one.
	// If multiple hostnames are listed e.g. in an entry in the /etc/hosts file,
	// the current Go implementation returns them in that order.

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Add the machine's hostname to /etc/hosts, e.g. "127.0.0.1 myhost" or its real IP
  2. Fix /etc/resolv.conf or the DNS server so the hostname resolves
  3. Verify with `getent hosts $(hostname)` or `nslookup $(hostname)`
  4. Set a fully-qualified hostname that already resolves in your DNS zone

Example fix

// /etc/hosts, before
127.0.0.1 localhost
// after
127.0.0.1 localhost
10.0.0.5 tablet-1.example.com tablet-1
Defensive patterns

Strategy: validation

Validate before calling

func hostnameResolves() error {
    h, _ := os.Hostname()
    ips, err := net.LookupHost(h)
    if err != nil || len(ips) == 0 {
        return fmt.Errorf("hostname %q does not resolve: %v", h, err)
    }
    return nil
}

Try / catch

fqdn, err := netutil.FullyQualifiedHostname()
if err != nil {
    log.Warn("FQDN lookup failed; check /etc/hosts and resolv.conf", slog.Any("error", err))
    return err
}

Prevention

When it happens

Trigger: FullyQualifiedHostname (or callers like BuildTabletFromInput, ExecuteBackup, populateListeningURL) run on a host whose hostname does not resolve to any IP via /etc/hosts or DNS.

Common situations: Kubernetes pods or containers where the pod hostname is absent from /etc/hosts; DNS server outages; /etc/hosts edited to remove the local entry; hostname set to something only resolvable via a broken resolver config.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/e26df5ac7fca8767. Report an issue: GitHub.