“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.”
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.
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
Print the exact URL. Check the host and the port.
Run curl with details. The first lines show the address that failed.
curl -v https://example.comTest the port.
nc -vz example.com 443Show the proxy variables.
env | grep -i proxy
How to fix it
Start the service if it is yours. Use the port it prints.
Force IPv4 to test an IPv6 fault.
curl -4 -v https://example.comUnset a wrong proxy.
unset https_proxy http_proxyTurn off the VPN for a short test. Turn it on again after.
With Kilobat
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.comThese Kilobat checks are free. AI agents run them through MCP with
diagnose_connectionanddiagnose_network. See Find why one site or API won't 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.
Sources
Checked on 29 October 2026.