# Apple container CLI No Internet on macOS 27.2.1

> Apple containers on the default network lost DNS and internet because InternetSharing stopped building the NAT bridge.

- Author: Curtis Miller
- Published: 2026-12-03
- Categories: gotchas, how-to, macos
- Canonical URL: https://millarian.com/posts/apple-container-no-internet-internetsharing/

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:

```text
fatal: unable to access 'https://github.com/example/app.git/': CONNECT tunnel failed, response 500
```

curl said the same thing in its own words:

```text
curl: (56) CONNECT tunnel failed, response 500
```

The proxy's log showed the real problem. It couldn't resolve anything:

```text
ERROR opensock: Could not retrieve address info for github.com:443: Temporary failure in name resolution
```

Anything else on the `default` network failed the same way, like Python tools trying to fetch rules:

```text
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 `pf` firewall 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:

```bash
sudo killall InternetSharing
container system stop
container system start
```

After 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:

```bash
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](https://github.com/apple/container/issues/2577). If networking looks flaky right after a restart, give it a moment before you start changing things.
