“Could not connect to the server” (NSURLErrorDomain -1004) on Mac
The app found the address of the server, but the connection did not open. The server refused it, or something on the path blocked it.
My Mac has this problem: “Could not connect to the server” (NSURLErrorDomain -1004) on Mac. Read https://kilobat.app/guides/nsurl-error-1004-could-not-connect-to-the-server.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
- An app shows “Could not connect to the server.” with error -1004.
- Console or a log shows NSURLErrorDomain Code=-1004.
- Safari shows the similar message “can’t connect to the server”.
Likely causes
- The server is down or does not listen. Nothing accepts connections on that port.
- A local server is not running. For
localhost, your own server must run. See Port already in use on a Mac. - A firewall, filter, VPN or proxy. Something blocks the port or the host.
- A wrong address or port. The app uses an old URL.
How to check
Test the port with a 5-second timeout.
nc -vz -G 5 example.com 443Request the page and show each step of the connection.
curl -v -o /dev/null https://example.comFor a local address, see what listens on the port.
lsof -nP -iTCP:3000 -sTCP:LISTEN
How to fix it
Open the same address on another device. If it fails there too, the server or the network is the cause.
Start the local server and use the port that it prints.
Turn off a VPN, proxy or filter for a test, then turn it on again.
Check the URL in the app for the right host and port.
Try again later. A busy server can recover.
With Kilobat
Check Wi-Fi, the router, the internet, DNS and login pages in one step.
kilobat diagnoseIf one site or service fails, find the layer that stops it.
kilobat why example.comThe CLI is free. In the app, the advice from these checks is part of Kilobat Pro. See Find why one site or API won't connect.
Questions
How is -1004 different from -1001?
-1004 is a refused or blocked connection. -1001 is a timeout. See “The request timed out.” on Mac.
Why does localhost give -1004?
Nothing listens on the port, or the server listens on another address.
Sources
- Error text in CFNetwork.framework, macOS 27.2 (Localizable.loctable)
- curl(1) and nc(1), man page installed with macOS 27.2
Checked on 29 October 2026.