Claude Code: --dangerously-skip-permissions cannot be used with root
Claude Code refuses to bypass its permission checks when it runs as the root user, or under sudo. The exact message, why Claude Code prints it, and the fix.
Updated November 23, 2026 · Checked against Claude Code 2.1.308, reproduced in EnvHaven 1.9.0
The message
--dangerously-skip-permissions cannot be used with root/sudo privileges for security reasons
What it means
Claude Code refuses to bypass its permission checks when it runs as the root user, or under sudo. Containers often run as root by default, which is where most people meet this.
Fix
- Run Claude Code as an ordinary user: create one (
useradd -m dev) and runclaudeas that user. - In a Dockerfile, add a non-root user and switch to it with
USER devbefore the command that starts Claude Code. - If you only need fewer prompts rather than none, use
--permission-mode acceptEdits, which works as root.
In an EnvHaven workspace
No. Workspaces run agents as the unprivileged abc user, and Claude Code starts in bypass mode there without this error.
Where this comes from
This message was produced by Claude Code (Claude Code 2.1.308) itself, in a throwaway EnvHaven 1.9.0 container, on 2026-11-23; the text above is copied from that output.