cURL error 6 🐘 PHP

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

  1. nslookup api.example.com on the server
  2. Fix the URL
  3. Check /etc/resolv.conf

Detailed fix by platform

PHP

  1. Log the full URL before the request to catch typos and missing environment variables

How to diagnose

  1. Hostname — Exactly what host?
  2. 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.