AgentFixFind a fix
CodexConfirmed workaroundUpdated Sep 23, 2026

bwrap loopback Failed RTM_NEWADDR: Operation not permitted

Fix the Codex Linux sandbox bwrap loopback RTM_NEWADDR error with the current Ubuntu AppArmor profile guidance.

Exact error

Match the message before using the fix

bwrap: loopback: Failed RTM_NEWADDR: Operation not permittedbwrap: Failed RTM_NEWADDR: Operation not permitted

Quick answer

Start here

Install the distribution `bubblewrap` package and verify Codex resolves `/usr/bin/bwrap`. On Ubuntu 24.04, install and load the packaged `bwrap-userns-restrict` AppArmor profile using the current OpenAI prerequisite steps. Prefer that narrow profile over disabling the AppArmor unprivileged-user-namespace restriction system-wide.

Diagnosis

Why it happens

  • Codex uses the first `bwrap` executable on PATH; without a distribution binary it can fall back to a bundled helper that also needs unprivileged user namespace support.
  • Ubuntu 24.04 can restrict unprivileged user namespaces through AppArmor even when the general user-namespace sysctls appear enabled.
  • Older reports mention a legacy Landlock flag, but current official guidance instead documents installing bubblewrap and loading its AppArmor profile.

Safest first

Fixes, in order

01

Install and verify the distribution bubblewrap package

Applies when: Linux or WSL2 where `bwrap` is absent, bundled, or resolves unexpectedly

Current OpenAI documentation recommends the package-manager build and says Codex uses the first `bwrap` on PATH.

  1. Install `bubblewrap` from the Ubuntu or Debian package repository.
  2. Run `command -v bwrap` and `bwrap --version`.
  3. Open a new shell so Codex receives the updated PATH.
sudo apt update
sudo apt install bubblewrap
command -v bwrap
bwrap --version

Expected: `command -v bwrap` resolves the distribution binary, normally `/usr/bin/bwrap`.

02

Load the Ubuntu 24.04 bwrap AppArmor profile

Applies when: The distribution bwrap is installed but the RTM_NEWADDR or user-namespace error remains on Ubuntu 24.04

OpenAI's current sandbox prerequisites provide a profile-specific path that retains the global AppArmor restriction.

  1. Install `apparmor-profiles` and `apparmor-utils`.
  2. Copy the packaged extra profile into `/etc/apparmor.d` with mode 0644.
  3. Load the profile with `apparmor_parser -r`.
  4. Retry the smallest sandbox command before running a full task.
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
sudo apparmor_parser -r /etc/apparmor.d/bwrap-userns-restrict
codex sandbox linux /bin/pwd

Expected: The bwrap sandbox creates its namespace and prints the working directory without RTM_NEWADDR failure.

03

Check the restriction without disabling it

Applies when: The profile path is unavailable or loading it did not help

A system-wide sysctl change broadens the host security boundary and should not be the default troubleshooting step.

  1. Record `sysctl kernel.apparmor_restrict_unprivileged_userns` and `sysctl user.max_user_namespaces`.
  2. Check AppArmor logs for a denial involving `bwrap`.
  3. Confirm the installed profile path matches the distribution package.
  4. Escalate with the Codex, OS, kernel, bwrap, and AppArmor versions instead of disabling the restriction globally.

Expected: You identify the missing profile or capture a precise policy denial without weakening all unprivileged user namespaces.

Verification

Prove the fix worked

  1. Run `codex sandbox linux /bin/pwd` and confirm it exits successfully.
  2. Run a harmless command in a normal Codex workspace-write session.
  3. Verify the global `kernel.apparmor_restrict_unprivileged_userns` setting remains enabled if it was enabled before.

Escalation

If it still fails

  • Do not disable AppArmor globally as the first response; use the bwrap-specific profile documented by OpenAI.
  • Do not rely on the old `use_legacy_landlock` report without checking whether your current Codex build still supports that behavior.
  • Include the exact bwrap path, Ubuntu release, kernel, and AppArmor denial when reporting the remaining failure.

Scope

Environment and version notes

  • The original reports covered Codex CLI 0.115.0 and 0.117.0 on Ubuntu 24.04.
  • The current OpenAI sandbox documentation explicitly covers Ubuntu 24.04 and the `bwrap-userns-restrict` profile.
  • Official prerequisites and issue status rechecked September 23, 2026.

Evidence

Sources

Source labels describe the evidence available on the checked date. A closed issue is not automatically a shipped fix.