LightAtom

curl: (6) Could Not Resolve Host: How to Fix It

curl couldn't turn the host name into an IP address. Typos, shell quoting, proxy settings and DNS problems are the usual causes.

curl: (6) Could not resolve host

curl asked the system to look up the host name in your URL and the lookup failed, so it never connected.

Quick checks

  • Print the host curl sees: look at the name in the error message for stray quotes or characters.
  • Run `dig +short example.com`.
  • Check proxy variables with `env | grep -i proxy`.

Fixes on Mac

  1. Fix quoting

    1. Quote URLs that contain ?, & or *, or zsh may mangle them: curl 'https://example.com/a?b=1&c=2'.
    2. Smart quotes pasted from documents (“ ”) become part of the host name; retype them.
  2. Check proxy environment variables

    1. If HTTPS_PROXY or ALL_PROXY points to a proxy that's gone, unset it: unset https_proxy HTTPS_PROXY all_proxy ALL_PROXY.
  3. Fix DNS

    1. Flush: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder.
    2. Test a public resolver: dig @1.1.1.1 example.com.
    3. For a one-off, force an address: curl --resolve example.com:443:203.0.113.10 https://example.com/.

Fixes on Windows

  1. Same checks

    1. Use double quotes in cmd, check set | findstr /i proxy, and run ipconfig /flushdns.

Other devices

  1. Docker and CI

    1. Containers use their own DNS: check /etc/resolv.conf inside the container and the Docker daemon's DNS settings.

Still not working?

“nodename nor servname provided, or not known” is the macOS wording of the same lookup failure (getaddrinfo's EAI_NONAME), seen in Python, Ruby and other tools. The same fixes apply.

See what’s happening

LightAtom's connections view shows whether curl connects at all once the name resolves, with the domain beside the address.

Frequently asked questions

What does curl error 6 mean?

CURLE_COULDNT_RESOLVE_HOST: the host name in the URL couldn't be resolved to an address.

What does “nodename nor servname provided, or not known” mean?

It's macOS's message for a failed name lookup: the host name doesn't resolve, often due to a typo, missing network or DNS issue.

Why does the URL work in a browser but not curl?

Browsers may use their own DNS (DoH) or a proxy configured in the browser, while curl uses system DNS and environment variables. Compare the two settings.

LightAtom team

The people who build LightAtom, a network monitor for macOS.