---
title: "Could not connect to the server (NSURLErrorDomain -1004) on Mac · Kilobat Guides"
url: "https://kilobat.app/guides/nsurl-error-1004-could-not-connect-to-the-server"
description: "An app shows Could not connect to the server, NSURLErrorDomain error -1004. Find if the server, a firewall or a proxy refuses you."
---

# “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.

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

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.

Applies to: macOS 13 Ventura and later. The text was checked in CFNetwork on macOS 27.2. · Checked: 29 October 2026

## 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](https://kilobat.app/guides/port-already-in-use).
- **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

1. Test the port with a 5-second timeout.

   ```
   nc -vz -G 5 example.com 443
   ```
2. Request the page and show each step of the connection.

   ```
   curl -v -o /dev/null https://example.com
   ```
3. For a local address, see what listens on the port.

   ```
   lsof -nP -iTCP:3000 -sTCP:LISTEN
   ```

## How to fix it

1. Open the same address on another device. If it fails there too, the server or the network is the cause.
2. Start the local server and use the port that it prints.
3. Turn off a VPN, proxy or filter for a test, then turn it on again.
4. Check the URL in the app for the right host and port.
5. Try again later. A busy server can recover.

## With Kilobat

1. Check Wi-Fi, the router, the internet, DNS and login pages in one step.

   ```
   kilobat diagnose
   ```
2. If one site or service fails, find the layer that stops it.

   ```
   kilobat why example.com
   ```
3. The 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](https://kilobat.app/guides/recipes/why-cant-it-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](https://kilobat.app/guides/request-timed-out).

**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.

## Related guides

- [“Safari can’t connect to the server” on Mac](https://kilobat.app/guides/safari-cant-connect-to-server): Safari found the address of the site, but the connection to the server did not open.
- [Port already in use on a Mac](https://kilobat.app/guides/port-already-in-use): Only one process can listen on a TCP port and address.
- [“The request timed out.” on Mac](https://kilobat.app/guides/request-timed-out): This is the macOS text for error -1001.
- [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.
- [IPv6 problems on a Mac](https://kilobat.app/guides/ipv6-problems-mac): Most networks give a Mac both IPv4 and IPv6 addresses.
