ProjectStack
docker

Temporary failure in name resolution / Could not resolve host

A process inside your container can't resolve domain names. DNS resolution is failing, which means the container can't look up the IP address for any external hostname. This is a container networking configuration issue, not a problem with the application code itself.

Common causes

  • Docker's internal DNS is unreachable — this can happen if the host DNS is misconfigured
  • The container is using host networking mode with a broken /etc/resolv.conf on the host
  • A custom Docker network with no DNS configuration, or the DNS option wasn't set
  • Firewall or VPN software on the host blocking DNS traffic from reaching Docker containers

How to fix it

  1. Test basic DNS from a container: docker run --rm busybox nslookup google.com
  2. Set explicit DNS servers for Docker: add {"dns": ["8.8.8.8", "8.8.4.4"]} to /etc/docker/daemon.json, then restart Docker
  3. For a single container: docker run --dns 8.8.8.8 myimage
  4. In Docker Compose: add dns: ["8.8.8.8"] under the service definition

Example

$ docker run myapp curl: (6) Could not resolve host: api.example.com Temporary failure in name resolution

Container can't reach external services because DNS isn't working inside the container

Browse more errors

The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.