Error: getaddrinfo ENOTFOUND host / Name or service not known
DNS lookup for the hostname failed — the name is wrong, doesn’t exist, or this machine can’t resolve it.
Meaning
Before connecting, the client resolves the hostname to an IP. ENOTFOUND (Node), socket.gaierror / “Name or service not known” (Python, Linux) and “Could not resolve host” (curl) all mean that step failed.
Common causes
- Typo in hostname, or protocol included in a host field (
https://api.x.comwhere onlyapi.x.comis expected) - Internal hostname not resolvable from this network/container
- Docker service name used outside the compose network
- DNS server down / no internet / VPN required
- Domain expired or DNS record removed
⚡ Quick fix
- Resolve it yourself:
nslookup hostordig host - Pass only the hostname where a host is expected (no scheme, no path)
- Check VPN / corporate DNS, and
/etc/resolv.confinside containers - In Docker Compose, call services by their service name from inside the network
Detailed fix by platform
Linux
- Check DNS from the same machine/container:bash
nslookup api.example.com dig +short api.example.com cat /etc/resolv.conf docker compose exec app getent hosts db
How to diagnose
- Hostname — Exactly what string is resolved?
- DNS — Does nslookup work here?
- Network — VPN, container network or offline?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026