macOS Error Code -1004
The host was found, but the connection could not be established.
The host was found, but the connection could not be established.
| Code | -1004 |
| Product | macOS |
| Company / origin | Apple · United States |
| Category | Operating Systems |
| Platform / versions | macOS 12 and later · NSURLErrorDomain |
| Severity | error |
| Official source | Apple Developer: NSURLErrorDomain ↗ |
| Last verified | 2026-11-08 |
What does macOS error -1004 mean?
NSURLErrorCannotConnectToHost (-1004) means DNS succeeded but the TCP connection failed. The service may be down, the port may be closed, or a firewall may be blocking the connection.
Common causes
- The server is not listening on the requested port.
- A firewall or security group is blocking the connection.
- The server is reachable but refuses connections from this network.
How to fix it
- Step 1
Check the host and port with nc or curl from the same Mac.
- Step 2
Verify the service is running and the firewall allows the source.
- Step 3
Try another network to distinguish local filtering from server-side blocking.
When to escalate
Related codes
| Code | Name | What it means |
|---|---|---|
-1005 | The Network Connection Was Lost | The connection was established but then dropped. |
-1001 | The Request Timed Out | The request did not complete within the allowed time. |
-1003 | Cannot Find Host | The hostname could not be resolved. |
-1006 | Cannot Find Host | The DNS lookup for the host failed. |
-1009 | The Internet Connection Appears to Be Offline | The device is not connected to the internet. |
Source & verification
This page was checked against Apple Developer: NSURLErrorDomain on 2026-11-08. The code, product, and platform fields are kept separate from the explanation so corrections can be made without changing the URL.
Open Error Codes is independent and not affiliated with Apple. Always confirm destructive or security-sensitive steps with the official documentation.