cloudflare / cloudflare/workers-sdk

`wrangler dev` crashes and/or hangs while attempting to perform local network development with `--ip` on macOS with Firewall enabled

Open
#9,789 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
186

Description

### What versions & operating system are you using?

Wrangler 4.22.0 - macOS Sequoia 15.5

### Please provide a link to a minimal reproduction

Any project created from latest

### Describe the Bug

I've run into a few bugs while attempting to work around macOS Firewall restrictions for local network connections, and have identified a few hangs and crashes while doing so.

Some of these steps are ones that I've only pieced together myself and don't have a full understanding of, but it seems as if they should be working and the errors I'm observing are definitely not normal.

- On macOS, with the System Settings "Firewall" up (and no additional configuration) `wrangler dev --ip 192.168.x.x` (substituting the current machine's IP address) will result in repeated debug-level errors like so:
```
workerd/io/io-context.c++:377: info: uncaught exception; exception = workerd/jsg/_virtual_includes/iterator/workerd/jsg/value.h:1565: disconnected: jsg.Error: Network connection lost.
stack: 1017f61d0 1017f6d8e 1035d660f 10162e2b0 10162e770
workerd/jsg/util.c++:322: info: exception = kj/async-io.c++:60: disconnected: stream disconnected prematurely
stack: 1035e36a7 1035e38ba 1035d660f 101ebbc67 101ebc783 101ebea6a 101e9f790 101ea63a0 101eb8df0 100fd6540 1018391c0 101731b30
✘ [ERROR] workerd/io/worker.c++:2126: info: uncaught exception; source = Uncaught (in promise); stack = Error: Network connection lost.
```
Without `--log-level debug`, the CLI appears to hang while being nonfunctional. I'd expect here that the CLI would at least error out, as it isn't actually able to connect to the network in a meaningful way.

- On macOS, with the System Settings "Firewall" up but having configured `node_modules/@cloudflare/workerd-darwin-64/bin/workerd` as being allowed to accept incoming connections (e.g. `sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /home/projectname/node_modules/@cloudflare/workerd-darwin-64/bin/workerd`) `wrangler dev --ip 0.0.0.0` does startup, but the first request to the local address (`192.168.x.x:8787`) causes a silent crash like so:
```
*** Fatal uncaught kj::Exception: kj/async-io-unix.c++:1365: failed: setsocketopt(IPPROTO_TCP, TCP_NODELAY): Invalid argument
stack: 1032073f6 103207835 1031d060f 100c3c52e 100c3d2ba 100c40d3b 100c41573 100c41eca 100bdb1e3 10322b59a 10322b9bb 103229ec8 103229be0 100bc8bd6 20644852f
```

Here as well, the CLI appears to hang - the above error is only visible with `--log-level debug`. I would expect this configuration (allowing the `workerd` process to accept incoming connections and starting with `--ip 0.0.0.0`) to allow other devices to connect to the running process, but this exception appears to keep that from working.

---

## Workarounds

Disabling the macOS Firewall entirely appears to fix the issue, but feels unsafe.

---

## Impact

In combination, these two issues mean that it isn't possible to use `wrangler dev --ip` on macOS to serve a local Cloudflare worker to other devices on the local network, without entirely disabling the macOS Firewall on the host machine. At least, I haven't found a way to do so.

### Please provide any relevant error logs

[wrangler-2025-06-28_18-48-47_473.log](https://github.com/user-attachments/files/20962879/wrangler-2025-06-28_18-48-47_473.log)

[wrangler-2025-06-28_18-49-13_723.log](https://github.com/user-attachments/files/20962882/wrangler-2025-06-28_18-49-13_723.log)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.