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

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: