Skip to content

/errors/dns/getaddrinfo-enotfound

Error: getaddrinfo ENOTFOUND (DNS lookup failed)

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated 2026-10-20
tool
DNS
exit code
1
versions
Node.js 18+
os
any

getaddrinfo ENOTFOUND <host> means the operating system's resolver could not turn the host name into an IP address. The request never left the machine. Check the spelling, make sure you pass a host name and not a whole URL, and test DNS from the same environment.

Reproduce the error

.invalid is a reserved top-level domain that never resolves (RFC 2606):

bash
node -e 'require("dns").lookup("nonexistent.invalid", (err) => console.log(err.code, "-", err.message))'

Output

ENOTFOUND - getaddrinfo ENOTFOUND nonexistent.invalid

A URL instead of a host name

A frequent cause in code is passing a URL where only a host is expected:

bash
node -e '
const http = require("http");
http.get({ host: "https://example.com/api" }).on("error", (e) => console.log(e.code, "-", e.message));'

Output

ENOTFOUND - getaddrinfo ENOTFOUND https://example.com/api

Use http.get("https://example.com/api") or new URL(...) instead of putting the URL in host.

Check DNS from the same environment

bash
nslookup api.example.com
dig +short api.example.com
getent hosts api.example.com   # what the system resolver (and Node.js) sees on Linux

ENOTFOUND vs EAI_AGAIN

CodeMeaningUsual cause
ENOTFOUNDthe name does not exist (NXDOMAIN)typo, wrong domain, private zone not visible
EAI_AGAINtemporary resolver failureno network, DNS server unreachable, timeout

Sources