Codex CLI not working: the sandbox is usually why

Codex has one dominant category of confusing failure, and it is not a bug: the sandbox is doing exactly what it was configured to do, and the error message does not say so.

By the Continuum team. We build a workbench that runs Claude Code, Codex, and their peers, so the model rates quoted here are the ones our own cost analytics ship with.

The short version

Run codex doctor first. It checks runtime, auth, network reachability, config, terminal, and MCP in one command, and it has a JSON mode for support tickets. After that, assume the sandbox: network errors during package installs, silent write failures, and commands that fail only inside Codex are almost always workspace-write doing its job, because it disables network access by default. Check sandbox_mode and approval_policy before assuming anything is broken. The other frequent surprise is billing: codex login status tells you whether the session is on your ChatGPT plan or on an API key, which bills separately at standard API rates.

What you need to know
  • Start with codex doctor. One command, and it has a --json mode for bug reports.
  • Network errors on install: workspace-write disables the network by default.
  • Cannot write anything: the sandbox is read-only.
  • Billed per token: the session is signed in with an API key, not your plan.
  • Test with full access once, to isolate. Then put the boundary back.
  • On Linux and WSL2 the sandbox needs bubblewrap installed.

Start with codex doctor

Codex ships a single diagnostic that covers most of what you would otherwise check by hand. It landed in v0.131.0 and has grown since; as of August 2026 it reports runtime, authentication, network reachability, terminal environment, configuration, Git state, and MCP server resolution in one grouped, colour-coded report.

codex --version
codex doctor

# structured and redacted, for a bug report or a support ticket
codex doctor --json

The dominant cause

SymptomActuallyFix
ECONNREFUSED during npm installNetwork off in workspace-writeEnable network_access
EAI_AGAIN, DNS failures, hanging fetchesSameSame
Cannot write any fileSandbox is read-only--sandbox workspace-write
Cannot write outside the projectWorking as designedAdd a writable_roots entry
Cannot write to /tmpexclude_slash_tmp or exclude_tmpdir_env_var setUnset it, or add the path
A command works in your shell, not in CodexSandbox restrictionCheck the mode first
Constant approval promptsapproval_policy is untrustedUse on-request
No prompts at all, and edits everywhereSomeone left --yolo onPut the boundary back
The ten-second diagnosis. Diagnostic only.
# does it work with restrictions removed?
codex --sandbox danger-full-access --ask-for-approval never

# if yes, it was policy, not a bug. Fix the config; do not stay here.

The two dials, and what each one actually controls.

SettingValuesControls
sandbox_moderead-only, workspace-write, danger-full-accessWhat Codex can do
approval_policyuntrusted, on-request, neverWhen it has to ask

They are independent, which is why the failure is confusing: you can have a permissive approval policy and still be blocked by the sandbox, and the message you see comes from the command that failed rather than from Codex explaining its own policy. As of August 2026 the default pairing in a version-controlled folder is workspace-write with on-request.

The network default

This is the single highest-traffic Codex complaint, and it is one line of configuration. In workspace-write, outbound network access is off unless you turn it on.

~/.codex/config.toml, or $CODEX_HOME/config.toml if you set that.
sandbox_mode = "workspace-write"
approval_policy = "on-request"

[sandbox_workspace_write]
network_access = true
writable_roots = ["/Users/you/.cache/pnpm"]
Per-run, without touching the file.
codex -c sandbox_workspace_write.network_access=true

Billing and authentication

SymptomCauseFix
Charged per token despite a ChatGPT planSigned in with an API key, not the plancodex logout, then codex login
Login never completesNo browser, or a proxycodex login --device-auth
Asked to log in every launch~/.codex/auth.json not writableCheck ownership of ~/.codex
401 after a whileSession expiredcodex logout, then codex login
Works locally, fails on a serverNo browser on the hostDevice auth, or an API key
Signed in as the wrong workspaceMultiple ChatGPT workspacescodex login status to confirm
The three commands worth knowing.
codex login status        # the active method: ChatGPT sign-in, or an API key
codex logout && codex login

# headless box with no browser
codex login --device-auth

# or explicitly with a key, without leaving it in your shell profile
printenv OPENAI_API_KEY | codex login --with-api-key

Where the sandbox actually comes from

The sandbox is not one implementation, and knowing which one you are on explains most of the platform-specific weirdness.

Sandbox enforcement by platform, as of August 2026.

PlatformMechanismYou need to
macOSThe built-in Seatbelt frameworkNothing. It works out of the box.
Linux and WSL2bubblewrap, plus kernel filteringInstall bubblewrap with your package manager
Windows, PowerShellThe native Windows sandboxNothing
Windows, WSL2The Linux implementationInstall bubblewrap inside the distribution
sudo apt-get install bubblewrap    # Ubuntu and Debian
sudo dnf install bubblewrap        # Fedora

which bwrap                        # Codex uses the first bwrap on PATH

Everything else

SymptomCheck
codex: command not foundNew terminal, then PATH, then a moved Node prefix
Vanished after upgrading Nodenpm global prefix moved. Reinstall, or use Homebrew.
Behaviour changed overnightcodex --version, then the release notes
Slow in WSLThe project is on /mnt/c. Move it.
MCP server missingcodex doctor reports stdio command resolution and permissions
Answers feel shallow on a hard taskmodel_reasoning_effort. Values run minimal to xhigh.
Need to see what it actually didTurn on a log directory and tail it
Logs, when you need the real story.
# log_dir defaults to $CODEX_HOME/log. Setting it explicitly also turns on
# the opt-in plaintext TUI log, codex-tui.log, in that directory:
codex -c log_dir=./.codex-log
tail -F ./.codex-log/codex-tui.log

# non-interactive mode prints its messages inline, so there is no file to watch
codex exec "run the test suite and summarise failures"

Questions people ask

codex doctor. As of August 2026 it checks runtime, authentication, network reachability for the provider you are actually using, terminal environment, configuration, Git state, and MCP servers in one command, and codex doctor --json produces a redacted report you can attach to a bug report.

Because workspace-write disables outbound network access by default. Set network_access = true under [sandbox_workspace_write] in config.toml when you need it, or pass it for one run with codex -c sandbox_workspace_write.network_access=true.

The sandbox is probably read-only. Run with --sandbox workspace-write, or set sandbox_mode in config.toml. If it can write inside the project but not outside, that is workspace-write working correctly; add the path to writable_roots rather than removing the sandbox.

Run once with --sandbox danger-full-access --ask-for-approval never. If the failure disappears, it was policy rather than a defect. Then fix the configuration narrowly instead of staying without a boundary.

The session is authenticated with an API key rather than your ChatGPT sign-in, and OpenAI bills API key usage through your Platform account at standard API rates. Run codex login status to see the active method, then codex logout and codex login to sign in with ChatGPT. To pin a machine to one rail, set forced_login_method to chatgpt in config.toml.

Use codex login --device-auth, which completes the flow on another device. Alternatively pipe a key in with printenv OPENAI_API_KEY | codex login --with-api-key, or copy ~/.codex/auth.json from an already authenticated machine and treat it like a password.

Yes. In PowerShell it uses the native Windows sandbox, and in WSL2 it uses the Linux implementation, which needs bubblewrap installed inside the distribution. Codex prints a startup warning when it cannot enforce the sandbox, and that warning is worth reading rather than dismissing.

log_dir defaults to $CODEX_HOME/log, and setting it explicitly also turns on the opt-in plaintext TUI log. Start with codex -c log_dir=./.codex-log and tail ./.codex-log/codex-tui.log. Non-interactive codex exec prints its messages inline instead, and honours RUST_LOG.

Sources

Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.

  1. Codex: sandboxing
  2. Codex: authentication
  3. openai/codex releases
  4. OpenAI Codex documentation
Try it

See what it
was allowed to do.

Continuum surfaces sandbox and approval state per session, so a refusal is explicable rather than mysterious.

free app · your subscriptions · local-first