---
title: "curl: (6) Could not resolve host on Mac: fix DNS for Terminal · Kilobat Guides"
url: "https://kilobat.app/guides/curl-could-not-resolve-host.html"
description: "curl on your Mac says (6) Could not resolve host. Check the name, the DNS servers, a proxy or VPN, and the macOS resolver from Terminal."
---

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](https://kilobat.app/guides/dns-server-not-found.html).
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](https://kilobat.app/guides/flush-dns-cache-mac.html).

## 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](https://kilobat.app/guides/recipes/why-cant-it-connect.html).

## 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](https://kilobat.app/guides/proxy-settings-breaking-apps.html).

## Sources

- [curl: libcurl error codes](https://curl.se/libcurl/c/libcurl-errors.html)
- 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.

## Related guides

- [Git: “Could not resolve host: github.com” on Mac](https://kilobat.app/guides/git-could-not-resolve-host-github.html): Git could not get an address for github.com.
- [DNS not resolving on a Mac](https://kilobat.app/guides/dns-server-not-found.html): When DNS fails, the Mac cannot change a name such as apple.com into an IP address.
- [Proxy settings stop apps from connecting on a Mac](https://kilobat.app/guides/proxy-settings-breaking-apps.html): A proxy setting sends traffic through another server.
- [Homebrew fails with “curl: (28)” on Mac](https://kilobat.app/guides/homebrew-curl-28-timed-out.html): Homebrew downloads with curl.
- [Internal names do not resolve on a VPN](https://kilobat.app/guides/vpn-split-dns-internal-names.html): macOS can send queries for one domain to one DNS server and other queries to another.
