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
Fix quoting
- Quote URLs that contain
?,&or*, or zsh may mangle them:curl 'https://example.com/a?b=1&c=2'. - Smart quotes pasted from documents (“ ”) become part of the host name; retype them.
- Quote URLs that contain
Check proxy environment variables
- If
HTTPS_PROXYorALL_PROXYpoints to a proxy that's gone, unset it:unset https_proxy HTTPS_PROXY all_proxy ALL_PROXY.
- If
Fix DNS
- Flush:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder. - Test a public resolver:
dig @1.1.1.1 example.com. - For a one-off, force an address:
curl --resolve example.com:443:203.0.113.10 https://example.com/.
- Flush:
Fixes on Windows
Same checks
- Use double quotes in cmd, check
set | findstr /i proxy, and runipconfig /flushdns.
- Use double quotes in cmd, check
Other devices
Docker and CI
- Containers use their own DNS: check
/etc/resolv.confinside the container and the Docker daemon's DNS settings.
- Containers use their own DNS: check
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.