{"record":{"id":"e26df5ac7fca8767","repo":"vitessio/vitess","slug":"fullyqualifiedhostname-failed-to-lookup-the-ip-of","errorCode":null,"errorMessage":"FullyQualifiedHostname: failed to lookup the IP of this machine's hostname (%v): %v","messagePattern":"FullyQualifiedHostname: failed to lookup the IP of this machine's hostname \\((.+?)\\): (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"go/netutil/netutil.go","lineNumber":73,"sourceCode":"}\n\n// FullyQualifiedHostname returns the FQDN of the machine.\nfunc FullyQualifiedHostname() (string, error) {\n\t// The machine hostname (which is also returned by os.Hostname()) may not be\n\t// set to the FQDN, but only the first part of it e.g. \"localhost\" instead of\n\t// \"localhost.localdomain\".\n\t// To get the full FQDN, we do the following:\n\n\t// 1. Get the machine hostname. Example: localhost\n\thostname, err := os.Hostname()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"FullyQualifiedHostname: failed to retrieve the hostname of this machine: %v\", err)\n\t}\n\n\t// 2. Look up the IP address for that hostname. Example: 127.0.0.1\n\tips, err := net.LookupHost(hostname)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"FullyQualifiedHostname: failed to lookup the IP of this machine's hostname (%v): %v\", hostname, err)\n\t}\n\tif len(ips) == 0 {\n\t\treturn \"\", fmt.Errorf(\"FullyQualifiedHostname: lookup of the IP of this machine's hostname (%v) did not return any IP address\", hostname)\n\t}\n\t// If multiple IPs are returned, we only look at the first one.\n\tlocalIP := ips[0]\n\n\t// 3. Reverse lookup the IP. Example: localhost.localdomain\n\tresolvedHostnames, err := net.LookupAddr(localIP)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"FullyQualifiedHostname: failed to reverse lookup this machine's local IP (%v): %v\", localIP, err)\n\t}\n\tif len(resolvedHostnames) == 0 {\n\t\treturn \"\", fmt.Errorf(\"FullyQualifiedHostname: reverse lookup of this machine's local IP (%v) did not return any hostnames\", localIP)\n\t}\n\t// If multiple hostnames are found, we return only the first one.\n\t// If multiple hostnames are listed e.g. in an entry in the /etc/hosts file,\n\t// the current Go implementation returns them in that order.","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/netutil/netutil.go#L55-L91","documentation":"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.","triggerScenarios":"FullyQualifiedHostname (or callers like BuildTabletFromInput, ExecuteBackup, populateListeningURL) run on a host whose hostname does not resolve to any IP via /etc/hosts or DNS.","commonSituations":"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.","solutions":["Add the machine's hostname to /etc/hosts, e.g. \"127.0.0.1 myhost\" or its real IP","Fix /etc/resolv.conf or the DNS server so the hostname resolves","Verify with `getent hosts $(hostname)` or `nslookup $(hostname)`","Set a fully-qualified hostname that already resolves in your DNS zone"],"exampleFix":"// /etc/hosts, before\n127.0.0.1 localhost\n// after\n127.0.0.1 localhost\n10.0.0.5 tablet-1.example.com tablet-1","handlingStrategy":"validation","validationCode":"func hostnameResolves() error {\n    h, _ := os.Hostname()\n    ips, err := net.LookupHost(h)\n    if err != nil || len(ips) == 0 {\n        return fmt.Errorf(\"hostname %q does not resolve: %v\", h, err)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"fqdn, err := netutil.FullyQualifiedHostname()\nif err != nil {\n    log.Warn(\"FQDN lookup failed; check /etc/hosts and resolv.conf\", slog.Any(\"error\", err))\n    return err\n}","preventionTips":["Ensure every node's hostname has an entry in /etc/hosts or DNS","Include hostname resolution in node readiness checks","Keep /etc/resolv.conf pointing at healthy resolvers"],"tags":["network","dns","hostname","lookup"],"backgroundTag":"hostname-resolution-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}