---
title: "“curl: (7) Failed to connect” on Mac · Kilobat Guides"
url: "https://kilobat.app/guides/curl-7-failed-to-connect"
description: "curl on your Mac stops with (7) Failed to connect. Check the port, the service, a firewall, a proxy, and the address that curl tried."
---

# “curl: (7) Failed to connect” on Mac

curl exit code 7 reports a failed step. The curl documentation says: “Failed to connect() to host or proxy.”

**Fix this with your agent**Copies a prompt for Claude Code, Codex or any agent that can use Terminal.

My Mac has this problem: “curl: (7) Failed to connect” on Mac. Read https://kilobat.app/guides/curl-7-failed-to-connect.md and work through it with me. Install the Kilobat CLI if it’s missing: brew install seifip/kilobat/kilobat. Run the guide’s Terminal and kilobat checks yourself and tell me what you find. List the steps only I can do. Ask before you change any setting.

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: (7) Failed to connect to host port 443`.
- The text often adds “Couldn't connect to server” or “Connection refused”.
- Scripts and installers stop with exit code 7.

## Likely causes

- **Nothing listens on the port.** The service is down, or it uses another port.
- **A firewall or proxy.** A firewall can refuse the connection. curl also fails when a proxy is set and unreachable.
- **A wrong address.** The host or port in the URL is wrong. A variable in a script can be empty.
- **An IPv6 or VPN route.** curl may try an address that the network cannot reach.

## How to check

1. Print the exact URL. Check the host and the port.
2. Run curl with details. The first lines show the address that failed.

   ```
   curl -v https://example.com
   ```
3. Test the port.

   ```
   nc -vz example.com 443
   ```
4. Show the proxy variables.

   ```
   env | grep -i proxy
   ```

## How to fix it

1. Start the service if it is yours. Use the port it prints.
2. Force IPv4 to test an IPv6 fault.

   ```
   curl -4 -v https://example.com
   ```
3. Unset a wrong proxy.

   ```
   unset https_proxy http_proxy
   ```
4. Turn off the VPN for a short test. Turn it on again after.

## With Kilobat

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

   ```
   kilobat why https://example.com
   ```
2. 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).

## Questions

**Does exit code 7 mean the host is down?**

Not always. curl could not connect to the host or the proxy. Find which with `curl -v`.

**What is the difference from (6)?**

Exit code 6 means the host name did not resolve. Code 7 means the connection failed. See [“curl: (6) Could not resolve host” on Mac](https://kilobat.app/guides/curl-could-not-resolve-host).

## Sources

- [curl: libcurl error codes](https://curl.se/libcurl/c/libcurl-errors.html)

Checked on 29 October 2026.

## Related guides

- [“curl: (6) Could not resolve host” on Mac](https://kilobat.app/guides/curl-could-not-resolve-host): curl exit code 6 means that curl could not get an address for the host name.
- [ERR_CONNECTION_REFUSED in Chrome on Mac](https://kilobat.app/guides/err-connection-refused): ERR_CONNECTION_REFUSED is a Chrome network error.
- [Homebrew fails with “curl: (28)” on Mac](https://kilobat.app/guides/homebrew-curl-28-timed-out): Homebrew downloads with curl.
- [Proxy settings stop apps from connecting on a Mac](https://kilobat.app/guides/proxy-settings-breaking-apps): A proxy setting sends traffic through another server.
