Skip to content
Latchkey

git/curl "Could not resolve host" (DNS in containers) in CI

The client asked the resolver to look up a hostname and got nothing back. This is name resolution failing outright: the DNS server is unreachable, unset, or has no record, so no connection is even attempted.

What this error means

git, curl, npm, or apt stops with "Could not resolve host: <name>". curl reports exit code 6. It commonly appears only inside a job container, while the host runner resolves the same name.

Terminal
curl: (6) Could not resolve host: github.com
fatal: unable to access 'https://github.com/org/repo.git/':
Could not resolve host: github.com

Common causes

The container has no working resolver

A job container with an empty or wrong /etc/resolv.conf (no nameserver line, or one pointing at an unreachable server) cannot resolve any name.

The name genuinely does not exist

A typo in the host, or an internal name that only resolves on a private DNS the runner cannot reach, returns NXDOMAIN.

How to fix it

Give the container a reachable nameserver

  1. Print /etc/resolv.conf inside the failing step to see if a nameserver is set.
  2. Configure a resolver for the container (for example via the service/container dns option or a Docker daemon dns setting).
  3. Re-run and confirm getent hosts <name> now returns an address.
.github/workflows/ci.yml
container:
  image: node:20
  options: --dns 8.8.8.8

Confirm the name resolves at all

Test resolution directly so you know whether the resolver or the record is the problem.

Terminal
getent hosts github.com || nslookup github.com

How to prevent it

  • Pin a known-good --dns for job containers instead of inheriting an empty resolv.conf.
  • Use fully qualified hostnames so a bad search domain cannot mangle the lookup.
  • Verify internal names resolve from the runner network before relying on them in CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →