Claude Code✓ Confirmed in official docsAdded Oct 24
How to allow bwrap with AppArmor when the Claude Code sandbox won't start on Ubuntu 24.04
On Ubuntu 24.04 and later, the default AppArmor policy stops bubblewrap (bwrap) from creating user namespaces, so the Claude Code sandbox on Linux may not start at all. Since v2.1.310, /sandbox and the sandbox startup warning name this restriction and how to lift it: add an AppArmor profile that grants the capability to bwrap only.
- Check whether the restriction is enforced. This works inside WSL2 too.
sysctl kernel.apparmor_restrict_unprivileged_userns
If it returns 0 or prints a No such file or directory error, there's no restriction and you can stop here. If it returns 1, continue.
- Create a profile for bwrap.
sudo tee /etc/apparmor.d/bwrap > /dev/null <<'EOF'
abi <abi/4.0>,
include <tunables/global>
profile bwrap /usr/bin/bwrap flags=(unconfined) {
userns,
include if exists <local/bwrap>
}
EOF
- Reload AppArmor.
sudo systemctl reload apparmor
- Restart Claude Code and open
/sandbox. If bubblewrap or socat is missing, only the Dependencies tab appears, so install them first.
sudo apt-get install bubblewrap socat
The profile applies only to bwrap itself, not to the commands it runs inside the sandbox.
Sources
Get notified when a new tip lands
Tip alerts only go out in the app. Install it and turn notifications on.