ENOTFOUND in Node.js — What It Means and How to Fix It
What the Node.js/npm error ENOTFOUND means and how to resolve it.
Published October 25, 2026
ENOTFOUND means DNS could not resolve the hostname to an IP address.
What it means and why it happens
Typical causes: a typo in the domain, no internet or DNS, or a service name that is unreachable from the container.
Read the full message: it names the file and line where the problem was detected, which is the best place to start.
What you see
run the code
Error: getaddrinfo ENOTFOUND api.exmaple.com
Practical examples
Code that triggers it
await fetch('https://api.exmaple.com')The fix
await fetch('https://api.example.com')Test DNS
nslookup api.example.com
dig +short api.example.comCommon mistakes
- Typos in hostnames.
- Docker network names.
- VPN DNS overrides.
Key takeaways
- ENOTFOUND: ENOTFOUND means DNS could not resolve the hostname to an IP address.
- Read the message and the line number first.
- Fix the cause, don't just silence the error.
FAQ
localhost ENOTFOUND?
Check your hosts file and use 127.0.0.1.
How do I find which line caused ENOTFOUND?
The error message and stack trace show the file and line; start there and work backwards.