Error messages

“curl: (6) Could not resolve host” on Mac

curl exit code 6 means that curl could not get an address for the host name. The curl documentation says: “The given remote host was not resolved.”

Applies to: The curl that comes with macOS and the Homebrew curl, on all current macOS versions.Checked: 29 October 2026

Symptoms

  • Terminal shows curl: (6) Could not resolve host: example.com.
  • Scripts and installers that use curl stop with exit code 6.
  • The same address opens in a browser, or it fails there too.

Likely causes

  • A typing error or an empty host. A variable in a script can be empty, so curl gets a wrong name.
  • No connection or no DNS. The Mac cannot reach a DNS server.
  • A VPN with its own DNS. Company names resolve only while the VPN is on.
  • A proxy that curl does not use. On networks that allow only a proxy, curl needs the proxy settings. It then lets the proxy resolve the name.

How to check

  1. Print the exact command. Make sure that the host name is correct.

  2. Look up the name through the macOS resolver.

    dscacheutil -q host -a name example.com
  3. Ask a public DNS server directly. An answer here, but not above, points to your DNS settings.

    dig +short example.com @1.1.1.1
  4. Show the proxy variables that curl reads.

    env | grep -i proxy
  5. Run curl with details. The first lines show the lookup.

    curl -v https://example.com

How to fix it

  1. If the macOS lookup fails too, fix DNS. See DNS not resolving on a Mac.

  2. If the network needs a proxy, set it for curl.

    export https_proxy=http://proxy.example.com:8080
  3. For a company name, connect the VPN first.

  4. Flush the DNS cache, then try again. See Flush the DNS cache on a Mac.

With Kilobat

  1. Kilobat's connection doctor tests the name layer by layer: network, proxy, DNS, rules, IPv4, IPv6, TLS and the server. It names the layer that failed.

    kilobat why example.com
  2. To use the proxy variables of a running process, add --app with its name.

    kilobat why https://example.com --app process:curl
  3. These Kilobat checks are free. AI agents run them through MCP with diagnose_connection and diagnose_network. See Find why one site or API won't connect.

Questions

Why does the browser work but curl does not?

The browser can use the system proxy or its own DNS. curl reads proxy variables such as https_proxy. See Proxy settings stop apps from connecting on a Mac.

Sources

  • curl: libcurl error codes
  • curl(1), EXIT CODES, man page installed with macOS 27.2
  • dscacheutil(1) and dig(1), man page installed with macOS 27.2

Sources checked on 29 October 2026. Man pages are the ones installed with macOS; open one with man <name> in Terminal.