Skip to content
Latchkey

curl "(6) Could not resolve host" inside a CI container

Error 6 is a pure DNS failure: curl never got an IP address for the hostname, so no connection was even attempted. Inside a CI container this usually means the container has no working resolver: an empty or wrong /etc/resolv.conf, a DNS server that is unreachable from the container network, or a name that only resolves inside a private zone the runner cannot reach.

What this error means

curl fails with "curl: (6) Could not resolve host: example.com". Reaching the same host by IP works, and other containers on the network may resolve fine.

Terminal
curl: (6) Could not resolve host: registry.internal.example.com

Common causes

The container has no working resolver

The container's /etc/resolv.conf is empty, points at an unreachable nameserver, or was not populated by the container runtime.

The name is private and not visible to the runner

An internal hostname resolves only via a private DNS zone or VPC resolver the CI network cannot reach.

How to fix it

Confirm and fix the resolver

  1. Print /etc/resolv.conf inside the container to see which nameservers it uses.
  2. Test resolution directly with getent hosts <name> or nslookup.
  3. Configure a reachable DNS server for the container (for example the Docker daemon --dns option or a compose dns: entry).
Terminal
cat /etc/resolv.conf
getent hosts registry.internal.example.com || echo "no DNS answer"

Provide DNS for service containers

For a container that must resolve a private name, point it at the resolver that serves that zone.

docker-compose.yml
services:
  app:
    image: my-app
    dns:
      - 10.0.0.2

How to prevent it

  • Verify /etc/resolv.conf is populated in custom container images.
  • Give containers explicit DNS servers when they must reach private zones.
  • Test name resolution in a setup step before the first network call.

Frequently asked questions

What causes ""curl: (6) Could not resolve host""?
The container's /etc/resolv.conf is empty, points at an unreachable nameserver, or was not populated by the container runtime.
How do I fix "curl: (6) Could not resolve host"?
Confirm and fix the resolver

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card