When the network works, but your Mac says otherwise
On two consecutive days I ran into two rather unusual network problems. In both, a Mac was struggling to reach something on the local network, while the tools I’d normally use to diagnose it said there was nothing wrong. The symptoms looked alike, but the explanations turned out to be completely different.
Launch agents that couldn’t reach the LAN #
The first one turned up in a smoke test of my AI agents on a headless Mac mini. The agents run as Claude Code sessions under Claude Code’s Remote Control servers, so I can reach them from the Claude apps on other machines. Set up this way, with the sign-in stored in a user’s login keychain, the servers run as launch agents inside that user’s login session rather than as system daemons.
From those sessions, every local address I tried failed instantly with “No route to host”: the NAS, another Mac’s address on the LAN, the Raspberry Pi. The router answered, and so did the internet. That same other Mac answered over its Tailscale address. And when I ran the same commands from Terminal, or from an SSH session on the same Mac, everything on the LAN answered perfectly. So did a job runner on the same machine that’s started as a launch daemon. The network was clearly fine. What differed was the process doing the asking.
That pattern, local traffic failing and the internet working, in one kind of process and not another, pointed at macOS Local Network privacy rather than routing. Apple’s technote TN3179, “Understanding local network privacy” (opens in a new tab) is clear about who gets local network access without having to ask: any daemon started by launchd, any program running as root, and command-line tools run from Terminal or over SSH, including the processes they start. Then comes the line that explained it: “The exception for launchd daemons doesn’t apply to launchd agents.” My servers were launch agents, and the sessions they started failed the same way. Every test I’d run from Terminal or SSH had been exempt by design, so it told me nothing about what the agents were allowed to do.
The obvious next step was to grant the permission. I allowed Claude under System Settings > Privacy & Security > Local Network and restarted the server. Nothing changed. I also investigated and ruled out the VPN’s routing as the explanation.
The system log was more helpful. At each failed connection, macOS looked the process up by its PID and found Claude Code, then looked it up by its executable’s UUID and found a different app: Claude Code’s small URL handler, whose executable is a link to the same claude binary. The log then recorded local network access as allowed by preference for the URL handler, followed by a “local network blocked” notification for my server. TN3179 has a warning that matches what I saw: local network privacy uses the main executable’s UUID, and if that executable “shares a UUID with other programs, local network privacy may behave weirdly”. That’s my best explanation for “allowed” and “blocked” appearing side by side. I haven’t reproduced it on its own to prove it. At the time I assumed every Claude Code update would bring a new UUID, which would make a fix that relies on the Settings toggle fragile. When I checked three installed versions later, two of them shared the same UUID, so a new release doesn’t necessarily mean a new UUID. Either way, a fix tied to the binary’s identity is one I’d rather not depend on.
Working round Local Network privacy #
I weighed a few ways round it. Running the servers as launch daemons would have exempted them, but daemons run outside the login session, and these servers need that user’s login keychain. TN3179’s own advice for a launch agent that isn’t installed with SMAppService is to set AssociatedBundleIdentifiers in its launchd property list, so macOS knows which app is responsible for it. I didn’t try that: macOS was already attributing the process to the URL handler and still blocking it, so I doubted it would change anything. Starting the servers from a Terminal login item would have borrowed Terminal’s exemption, at the cost of a fragile start-up on a Mac with no screen.
The option TN3179 itself suggests for site administrators, including those who manage CI systems, is different again, and it suits Macs that often run unattended, with nobody there to answer a prompt. Since macOS 15.5 there are two user defaults, one for wired Ethernet and one for Wi-Fi, that take networks you list in CIDR form out of local network privacy. In Apple’s words, the system then treats every address on that network “as if it were not a local network address”, and every program can reach it, whatever its Local Network privilege:
sudo defaults write com.apple.network.local-network AllowedEthernetLocalNetworkAddresses -array "192.168.1.0/24"
sudo defaults read com.apple.network.local-networkThat’s an example range. The settings affect the whole system, so they need sudo, and they don’t take effect until you restart. There’s a matching AllowedWiFiLocalNetworkAddresses key for Wi-Fi.
In the case I worked through, two changes went in with the same restart, one of them a macOS update. Afterwards the servers came back by themselves, and a session could reach the NAS and the other Mac again, but I can’t tell you which change did it. What I can say is that this setting is Apple’s documented control for the problem, and it doesn’t depend on Claude Code’s binary identity.
It also comes with a real trade-off. On a Mac with this setting, every program can reach that network without the privacy prompt. On a dedicated, unattended machine on a network you control, that can be a reasonable choice. On a laptop that travels, it’s a different decision. Either way, keep the range to the one network you mean, and remember that the common private ranges are used on plenty of other people’s networks too.
A NAS that wouldn’t resolve #
The day after I’d first spotted that, I was dealing with another network problem. This time a Mac couldn’t resolve the NAS by name, first the mini in the morning and then a second Mac in the afternoon. The symptoms felt familiar, but the problem was quite different, and once again the tools I was using to diagnose it were returning perfectly good results.
Looked up the way applications do it, through the Mac’s own resolver, the name wouldn’t resolve. Yet dig against each DNS server along the way returned the right address every time. On the second Mac, flushing the DNS cache fixed it straight away, and that Mac had been up for a couple of days, so a reboot wasn’t the trigger. When every server gives the right answer and the Mac still gets it wrong, the first thing to suspect is a cache.
To work out which cache, I followed the path a .lan lookup takes on these Macs. The Mac’s resolver hands .lan names to Tailscale’s MagicDNS. MagicDNS sends them, through a split-DNS route, to AdGuard Home on a Raspberry Pi. AdGuard passes .lan on to the router, which knows the names it hands out over DHCP. That’s four hops for one name.
Two measurements explained why a bad answer could stick.
The first was the positive answer. The router gave out the NAS’s address with a TTL of zero, so nothing along the way should have kept the correct answer.
The second was the negative answer. When I asked for a .lan name that doesn’t exist, it came back as NXDOMAIN carrying the root zone’s SOA, with a negative TTL of 86,400 seconds, a full day. It came back the same way at the router, at AdGuard and at MagicDNS.
The reason was in the forwarding. The router passed names it didn’t know back up to AdGuard, and from there, without a rule keeping .lan local, they could reach public DNS.
.lan isn’t delegated in the public DNS, so the root answers “no such name”. Resolvers are allowed to cache that negative answer, and RFC 2308 (opens in a new tab) sets how long: the TTL is “taken from the minimum of the SOA.MINIMUM field and SOA’s TTL”. On the day, that came to the full 86,400 seconds.
Taken together, that allows a failure like this. If a single lookup for the NAS ever went out to public DNS, the response would have allowed the negative answer to be cached for up to 24 hours, although I haven’t established how long macOS would actually keep it. While a resolver holds a negative answer, it normally answers from its cache rather than asking again. The good answer, cached for zero seconds, left nothing behind to fall back on. That’s the leading explanation, and I want to be clear that it’s an explanation rather than an observation. I never captured the failed answer for the NAS itself, and I had no record of the lookups that would show what sent one out. The Pi had restarted early that morning and the tailnet had changed overnight; either could have caused a gap, but neither is proven.
The fix was to give the local DNS server the answers itself. In AdGuard Home, a DNS rewrite (opens in a new tab) makes it answer a name with an address you choose instead of forwarding the query, for example nas.lan to 192.168.1.20. That suits machines with fixed addresses, such as DHCP reservations. Applying it took DNS down for a few seconds. Afterwards I asked for each name at AdGuard, at MagicDNS and through each Mac’s own resolver, and every one came back right, now with a TTL of 10 seconds from AdGuard. For those names, the answer no longer depends on the router or on the internet.
One-name rewrites like these only cover the names you list, though. Any other .lan name that isn’t known can still leak to public DNS and come back with the root’s NXDOMAIN and its 24-hour negative TTL. The obvious way to stop that, sending those queries back to the router, would loop, because the router sends them on to AdGuard, so it needs a different setting, and that’s one to test before you trust it. I also decided against two shortcuts: entries in /etc/hosts, which drift on every machine, and a second split-DNS server pointing lan straight at the router, which has the same leak.
If you hit something similar, work through it in this order, so you collect the evidence before you clear it:
- Reproduce it the way applications see it:
dscacheutil -q host -a name nas.lanasks the Mac’s own resolver, cache and all. - Compare with direct queries:
dig nas.lan @<each DNS server>.digtalks to DNS directly and skips the Mac’s cache, so it can tell you everything is fine while applications still fail. If the two disagree, the difference is your clue. - Capture what you see, from step 1 onwards: the answers, their TTLs, and for any NXDOMAIN, the SOA record in the authority section and its TTL. Flushing clears whatever the Mac was holding, so save the output first.
- Check whether misses leave your network: ask your DNS for a
.lanname that doesn’t exist. If the answer carries the root zone’s SOA, that suggests your unknown names are reaching public DNS. - Only now, flush the Mac’s cache:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder - Repeat the test from step 1 and compare. If it now works, that supports the idea that a cached answer was the problem.
- Then fix it for the longer term: answer the names you depend on locally, and consider a reserved name.
home.arpais set aside for home networks (RFC 8375 (opens in a new tab)), and in July 2024 ICANN reserved.internal(opens in a new tab) permanently for private use. A reserved name won’t stop a leak on its own, but it can’t clash with a real domain later.
Testing from the right place #
Each of those tests was a reasonable one to run. Terminal reached the LAN without trouble, because Terminal is exempt from Local Network privacy; the launch agent wasn’t. dig got the right address every time, because it goes straight to the DNS server and never touches the Mac’s resolver cache; the applications did. Both times, my tests were telling the truth about the wrong thing.
So before you trust a diagnostic result, ask what path it took and whether the failing program takes the same one. Test as the same kind of process, through the same resolver and the same privacy checks, rather than from the most convenient shell.