ENOTFOUND node network ai_generated true

Error: getaddrinfo ENOTFOUND hostname

ID: node/node-dns-resolution-failed

Also available as: JSON · Markdown
88%Fix Rate
90%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
20 active

Root Cause

DNS lookup failed for the target hostname. The system resolver cannot translate the domain name to an IP address.

generic

Workarounds

  1. 90% success Verify the hostname is correct and the DNS server is reachable
    Run 'nslookup hostname' or 'dig hostname' to confirm DNS resolution works at the OS level

    Sources: https://nodejs.org/api/dns.html

  2. 85% success Use dns.setServers() to specify custom DNS servers
    const dns = require('dns'); dns.setServers(['8.8.8.8', '8.8.4.4']); before making requests

    Sources: https://nodejs.org/api/dns.html#dnssetserversservers

Dead Ends

Common approaches that don't work:

  1. Retrying the request in a tight loop without backoff 75% fail

    DNS failures are often transient but require time to recover; flooding the resolver makes it worse

  2. Hardcoding IP addresses to bypass DNS 70% fail

    IP addresses change over time, especially for cloud services; breaks when infrastructure rotates

Error Chain

Leads to:
Preceded by:
Frequently confused with: