Skip to content
RU

Error: getaddrinfo ENOTFOUND — Why the Host Name Does Not Resolve

What it means: The system resolver found no address for the host name your code tried to connect to.

  1. Check the exact host name in the error
  2. Remove https:// and paths from host fields
  3. Resolve it with dig and getent hosts
  4. Fix DNS in the container or VPN

Test your URL now

Looks the name up in public DNS and shows every record it returns.

Check your domain's DNS →

What getaddrinfo ENOTFOUND means

Node.js resolves host names for http, net, fetch and most libraries with dns.lookup(), which «uses the operating system facilities to perform name resolution» and is implemented as a call to getaddrinfo(3) on libuv's threadpool (Node.js dns docs). When that call finds nothing, you get:

Error: getaddrinfo ENOTFOUND api.example.com
  { errno: -3008, code: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'api.example.com' }

The Node.js docs define ENOTFOUND as «DNS lookup failed», a failure «of either EAI_NODATA or EAI_NONAME», and note it is not a standard POSIX error. Per getaddrinfo(3), EAI_NONAME means «The node or service is not known» and EAI_NODATA means the host exists but has no network addresses defined. In DNS terms that is NXDOMAIN or a name with no A/AAAA record.

A different code, EAI_AGAIN (getaddrinfo EAI_AGAIN), is a temporary failure: the resolver could not be reached or returned a temporary error. ENOTFOUND is a definite «no such name»; EAI_AGAIN is «could not ask».

Causes

CauseWhat the error showsFix
Scheme or path in a host fieldgetaddrinfo ENOTFOUND https://api.example.comPass only the host, or pass a full URL to the URL parameter
Typo or wrong environment variableAn unexpected host, or undefinedPrint the resolved config at startup
The DNS record does not existdig returns NXDOMAIN or no A/AAAACreate the record
Internal name used outside the networkWorks on VPN or in the office onlyConnect the VPN or use the public name
Container DNSWorks on the host, fails in Docker or KubernetesCheck the container's /etc/resolv.conf and network
npm registry or proxy hostnpm ERR! getaddrinfo ENOTFOUND registry.npmjs.orgCheck network, proxy and registry in .npmrc

The first row accounts for a large share of reports. http.request({ host: 'https://api.example.com' }) looks up the literal string https://api.example.com as a host name, which cannot exist. Use host: 'api.example.com' or pass the URL string as the first argument.

Docker, Kubernetes and VPNs

Name resolution inside a container uses the container's own /etc/resolv.conf, not the host's. Containers on a user-defined Docker network resolve each other by name through Docker's embedded DNS; on the default bridge network they cannot (Docker bridge docs), so a compose-style service name used with plain docker run returns ENOTFOUND. In Kubernetes, a service name resolves only through the cluster DNS and only in the right namespace: db works from the same namespace, other namespaces need db.namespace.

Corporate VPNs often provide internal names through their own resolver. When the VPN is off, or a container does not inherit the VPN's DNS settings, internal names fail with ENOTFOUND while public names keep working.

docker run --rm --network mynet busybox nslookup db
kubectl run -it --rm dnscheck --image=busybox --restart=Never -- nslookup db.default

How to fix it

  1. Copy the host name from the error character by character. A scheme, a trailing slash, a port glued to the name or undefined points straight at the bug.
  2. Resolve it the way Node.js does (through the system resolver, including /etc/hosts), then directly in DNS:
    getent hosts api.example.com      # system resolver, like dns.lookup()
    dig +short api.example.com A      # public DNS only
    dig +short api.example.com AAAA
    If getent fails but dig works, the local resolver configuration is the problem; if both fail, the record is missing.
  3. Check the record in public DNS and create it if missing; see checking DNS records.
  4. In containers, run the same lookup inside the container and read its /etc/resolv.conf.
  5. For npm, check npm config get registry and npm config get proxy; a mistyped registry or proxy host produces the same error.

How to confirm the fix

node -e "require('dns').lookup('api.example.com', (e, a) => console.log(e ? e.code : a))"
# 203.0.113.10

Run it in the same environment as the failing app (host, container or CI job). The DNS lookup shows what public DNS returns for the name.

Related errors

A / AAAAIPv4 and IPv6 host addresses
MX RecordsDomain mail servers
TXT / SPFVerification & anti-spoofing
NS / SOAName servers & zone authority

Why teams trust us

12
DNS record types
SPF+DKIM
email protection
<1s
DNS response
3
check regions

How it works

1

Enter domain

2

Select record type

3

Get DNS response

What are DNS Records?

DNS (Domain Name System) translates domain names into IP addresses. DNS records are instructions that define where to route traffic, email, and how to verify domainownership.

Complete Lookup

Query all record types — A, AAAA, MX, NS, TXT, CNAME, SOA — in a single request.

Instant Results

Direct queries to authoritative servers. Results in milliseconds, no caching.

Security Checks

SPF, DKIM, and DMARC analysis to evaluate email protection against spoofing and phishing.

Export & History

Save check results. Compare DNS records before and after registrar changes.

Who uses this

DevOps

DNS check after deploy

Email marketers

SPF/DKIM/DMARC audit

SEO

DNS config audit

Sysadmins

DNS zone control

Common Mistakes

Missing SPF recordWithout SPF, emails may land in spam. Add a v=spf1 TXT record.
Single NS serverIf the only NS fails, the domain becomes unreachable. Use at least 2 NS servers.
CNAME conflicting with other recordsCNAME cannot coexist with MX or TXT on the same name — this violates RFC.
TTL set too highWith 86400s TTL, DNS changes take a full day. Lower TTL to 300 before migrations.
Missing PTR recordMail servers check PTR. Without it, emails may be rejected.

Best Practices

Set up SPF + DKIM + DMARCThe trio of records that protects your email from spoofing and improves deliverability.
Use 2+ NS serversDistribute NS servers across different networks for redundancy.
Lower TTL before migrationSet TTL to 300 at least 24-48 hours before an IP change for fast propagation.
Verify DNS after changesAfter updating records, confirm changes propagated correctly and no errors remain.
Add a CAA recordCAA restricts which Certificate Authorities can issue SSL certificates for your domain.

Get more with a free account

DNS check history, API keys and DNS change monitoring.

Sign up free

Learn more

Sources

Frequently Asked Questions

What is the difference between ENOTFOUND and EAI_AGAIN?

ENOTFOUND means the name definitely has no address. EAI_AGAIN is a temporary failure: the resolver could not be reached or asked to try again later.

Why does curl work but Node.js returns ENOTFOUND?

Check that both run in the same environment and that the host string in your code has no scheme or path. Inside Docker, the container's resolver may differ from the host's.

Why does npm install fail with getaddrinfo ENOTFOUND?

npm could not resolve the registry or proxy host. Check your connection, VPN, and the registry and proxy settings in .npmrc.

Does dns.lookup read /etc/hosts?

Yes. dns.lookup uses the operating system resolver through getaddrinfo, so /etc/hosts and the system DNS configuration apply. dns.resolve queries DNS servers directly.

Try the live tool that powered this guide

Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.