# Codex: bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted

> Codex's Linux sandbox uses bubblewrap (bwrap), which needs unprivileged user namespaces. The exact message, why Codex prints it, and the fix.

_Updated November 23, 2026_

## The message

```text
bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted
```

## What it means

Codex's Linux sandbox uses bubblewrap (bwrap), which needs unprivileged user namespaces. Ubuntu 24.04's AppArmor restriction (kernel.apparmor_restrict_unprivileged_userns=1) and many Docker or devcontainer setups block them, so bwrap fails while setting up the sandbox's loopback network and every sandboxed command, apply_patch included, fails.

## Fix

1. Install bubblewrap from your distribution (`sudo apt install bubblewrap`) so Codex uses the system bwrap.
2. On Ubuntu 24.04, load the bwrap AppArmor profile: `sudo apt install apparmor-profiles apparmor-utils`, `sudo install -m 0644 /usr/share/apparmor/extra-profiles/bwrap-userns-restrict /etc/apparmor.d/bwrap-userns-restrict`, then `sudo apparmor_parser -r /etc/apparmor.d/bwrap-userns-restrict`.
3. If that doesn't help, turn off the restriction: `sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0`.
4. Inside Docker, where the container is already the isolation boundary, run Codex with `--sandbox danger-full-access`.

## In an EnvHaven workspace

It can happen anywhere Codex runs; the fix above applies in a workspace too.

## Where this comes from

From Codex's documentation and issue tracker:

- [github.com/openai/codex/issues/29908](https://github.com/openai/codex/issues/29908)
- [learn.chatgpt.com/docs/sandboxing](https://learn.chatgpt.com/docs/sandboxing)
- [learn.chatgpt.com/docs/sandboxing](https://learn.chatgpt.com/docs/sandboxing)
- [learn.chatgpt.com/docs/agent-approvals-security](https://learn.chatgpt.com/docs/agent-approvals-security)

## Keep reading

- [Codex](https://envhaven.com/agents/codex)
- [Is Codex down?](https://envhaven.com/status/codex)
- [Every agent error](https://envhaven.com/errors)

Source: https://envhaven.com/errors/codex/bwrap-loopback-rtm-newaddr
