cURL error 6: Could not resolve host: api.example.com
PHP cURL couldn’t resolve the hostname via DNS.
Seen on:
PHP
Meaning
The server’s DNS lookup failed — typo in the URL, internal hostname, no DNS inside a container, or the host’s resolver is down.
Common causes
- Typo or scheme in the host field
- Host not resolvable from this server
- Container without DNS
- Temporary DNS outage
⚡ Quick fix
nslookup api.example.comon the server- Fix the URL
- Check /etc/resolv.conf
Detailed fix by platform
PHP
- Log the full URL before the request to catch typos and missing environment variables
How to diagnose
- Hostname — Exactly what host?
- DNS — Resolves from this machine?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026