I have a tool that runs things in Apple containers using the container CLI. Its containers reach the internet through a small tinyproxy container on the default network. One day every clone through that proxy failed:
fatal: unable to access 'https://github.com/example/app.git/': CONNECT tunnel failed, response 500curl said the same thing in its own words:
curl: (56) CONNECT tunnel failed, response 500The proxy's log showed the real problem. It couldn't resolve anything:
ERROR opensock: Could not retrieve address info for github.com:443: Temporary failure in name resolutionAnything else on the default network failed the same way, like Python tools trying to fetch rules:
Failed to resolve 'semgrep.dev' ([Errno -3] Temporary failure in name resolution)No gateway, no DNS, no internet, for every container on that network.
This was container 1.7.1 on macOS 27.2.1. If your Apple container has no internet or can't resolve DNS on the default network, this may be your problem too.
What I tried that didn't work
Quite a lot, and none of it helped:
- Rebooting, more than once.
- Uninstalling the container runtime with
-d(delete data) and reinstalling clean. - Quitting OrbStack.
- Removing a custom
pffirewall anchor.
The last one fooled me. Networking came back right after I removed the pf rules, so I blamed the firewall. It broke again later with no firewall at all. That recovery was coincidence.
The fix: restart InternetSharing and the container service
The default network relies on the macOS InternetSharing daemon for its NAT, and the daemon had stopped setting it up. Kill it (launchd starts it again), then restart the container system service:
sudo killall InternetSharing
container system stop
container system startAfter that, DNS resolved and networking held up through ten minutes of testing. It stayed working.
Check for it automatically
I got tired of diagnosing this by hand, so my tool's setup check now runs a quick probe:
container run --rm --network default alpine sh -c 'getent hosts registry.npmjs.org'If that fails, it offers to run the killall InternetSharing and the service restart. Resolving a real hostname is a better probe than pinging the gateway, because it exercises the NAT and DNS together.
A related gotcha: containers on two networks
One more thing I hit on the same setup. A container attached to two networks came up broken if another container had already used the second network since the service started. Restarting the service with nothing running and starting the container on two networks first avoided it. There is also a known report of replies being misrouted for minutes after a service restart, tracked in apple/container issue #2577. If networking looks flaky right after a restart, give it a moment before you start changing things.