Codex on Windows: install, sandbox, WSL and common errors
Run OpenAI Codex on Windows: the PowerShell install, the sandbox setup prompt (MXC, elevated, non-admin), WSL2, where files live, and fixes for common errors.
Codex runs natively on Windows 11, and on a fully updated Windows 10 (version 1809 or newer) on a best-effort basis, in three forms: the ChatGPT desktop app, the Codex CLI and the VS Code extension. For the CLI, run powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex" in PowerShell (or npm install -g @openai/codex), then run codex in a new PowerShell window and sign in with ChatGPT. Natively, Codex runs its commands in PowerShell inside a Windows sandbox: in the desktop app, MXC on Windows 11 builds that have it (the CLI uses MXC only if you turn on prefer_mxc), otherwise an “elevated” sandbox that needs one administrator approval, or a weaker non-admin one. Choose WSL2 instead when your code and tools live in Linux; WSL1 has been unsupported since Codex 0.115. Settings and sign-in live in %USERPROFILE%\.codex, which a Codex inside WSL does not share unless you point CODEX_HOME at it or sync the two folders. The current CLI is 0.171.0, released November 20, 2026.
Native Windows or WSL2
OpenAI’s Windows sandbox page says to “use the native Windows sandbox by default” and to choose WSL when you need Linux-native tooling, your work already lives in WSL2, or the native sandbox does not meet your needs. In WSL2, Codex is a Linux program with the Linux sandbox, and none of the Windows sandbox applies. Each form of Codex can do either:
| Form | Native (the default) | To run it in WSL2 |
|---|---|---|
ChatGPT desktop app | Commands run in PowerShell under the Windows sandbox | In Settings, switch the agent from Windows native to WSL, then restart the app |
Codex CLI | Install with the PowerShell script or npm, run in PowerShell or Windows Terminal | Install inside the distribution with the Linux script and run it there |
VS Code extension | Runs on Windows | Open the folder in WSL with Microsoft’s WSL extension: from a WSL shell run code ., or choose WSL: Reopen Folder in WSL |
One trade-off decides where projects should live. With the agent in WSL, OpenAI says to keep repositories under your Linux home, such as ~/code, because /mnt/c can be slower. With the native agent, the app’s docs say the opposite: keep the project on the Windows drive and reach it from WSL through /mnt/<drive>/, which is “more reliable than opening projects directly from the WSL filesystem.”
Install the Codex CLI on Windows
From a PowerShell window that is not running as administrator, OpenAI’s documented install is:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"Copied-ExecutionPolicy ByPass applies only to the PowerShell session it starts, so the script runs without you changing your policy. Reading the script, as of November 2026:
- It needs 64-bit Windows and installs the x64 or ARM64 build to match the PC.
- The
codex.exeyou run goes in%LOCALAPPDATA%\Programs\OpenAI\Codex\bin(setCODEX_INSTALL_DIRto choose another folder), and the releases themselves under%USERPROFILE%\.codex\packages\standalone. - It adds that folder to your user PATH, which PowerShell windows opened afterwards pick up; its closing message is “open a new PowerShell window and run: codex”.
- If it finds a copy installed with npm or bun, it warns that “PATH order decides which one runs” and offers to uninstall that copy.
Running the command again updates Codex, and so does codex update, which on a script install runs the same installer non-interactively; when an update seems not to take, updating Codex covers the usual cause, a second copy on the PATH. The npm route needs Node.js 16 or newer and installs the matching Windows build as a dependency:
npm install -g @openai/codex
Get-Command codex
codex --versionCopiedGet-Command shows which file runs; codex doctor checks the installation, config, sign-in and runtime. To pin a release, OpenAI’s deployment guide downloads the script and passes -Release:
Invoke-WebRequest -UseBasicParsing -Uri 'https://chatgpt.com/codex/install.ps1' -OutFile '.\codex-install.ps1'
powershell -ExecutionPolicy Bypass -File .\codex-install.ps1 -Release 0.171.0CopiedOne of the repository’s own pages lags: its install notes, even at the 0.171.0 tag, list “Windows 11 via WSL2” as the requirement, and the README’s list of release downloads names only macOS and Linux archives, though the same README gives the PowerShell install command above. OpenAI’s Windows docs, the installer and the releases, which include Windows builds for x64 and ARM64, all support native Windows. OpenAI’s Windows matrix calls Windows 11 the recommended baseline, a recent fully updated Windows 10 best effort (it relies on the ConPTY console, so 1809 or newer), and older Windows 10 builds not recommended.
Sign in
Run codex in a project folder and choose Sign in with ChatGPT, or run codex login; either opens your browser, and the browser hands the sign-in back to the terminal. codex login --with-api-key instead reads an OpenAI API key from standard input, billed at API rates. codex login status shows which method is active and codex logout clears it.
If the browser flow cannot get back to the CLI, OpenAI’s authentication page points to device code sign-in: choose Sign in with Device Code or run codex login --device-auth, after turning on device code sign-in in your ChatGPT security settings. The message you get while it is off, and the errors that look like it, are in the device code authorization guide. The sign-in is saved by default in %USERPROFILE%\.codex\auth.json, a plaintext file holding live tokens; set cli_auth_credentials_store = "keyring" in config.toml to keep it in the operating system’s credential store instead.
The Windows sandbox and its setup prompt
Codex runs the commands it chooses inside a sandbox that limits which folders they can write and whether they reach the network. Windows has three implementations, named as they appear in config.toml:
mxcuses Microsoft Execution Containers, Windows 11’s own process isolation, with no administrator setup, extra accounts or firewall rules. OpenAI recommends it where the PC has it.elevatedis the preferred fallback. Setting it up needs one administrator approval, after which commands run without administrator rights, as dedicated low-privilege Windows users behind firewall rules and filesystem permissions. The setup creates those users as local accounts, namedCodexSandboxOfflineandCodexSandboxOnlinein Codex’s source.unelevatedneeds no administrator. It runs commands with a restricted Windows token derived from your own, has weaker network isolation, and does not support denied read paths.
The first-run prompt
On a fresh Windows 11 machine the CLI shows a setup menu shortly after it starts, which OpenAI’s reply on a GitHub issue describes seeing on a clean install. In the 0.171.0 source its heading is “Set up the Codex agent sandbox to protect your files and control network access”, over three choices:
- Set up default sandbox (requires Administrator permissions) is
elevated. Windows asks for administrator approval, Codex shows “Setting up sandbox...”, and the result is saved as[windows] sandbox = "elevated". - Use non-admin sandbox (higher risk if prompt injected) is
unelevated. - Quit.
If you pick the non-admin sandbox now and want the stronger one later, run /setup-default-sandbox in a session. Whichever you choose, keep the boundary: OpenAI’s docs warn that full access mode means Codex “is not limited to your project directory and might perform unintentional destructive actions that can lead to data loss.”
MXC on Windows 11
MXC arrived in Windows 11 24H2 (build 26100.9278) and 25H2 (build 26200.9278), and Microsoft is still rolling it out, so a given PC may not have it yet. The desktop app picks MXC automatically for consumer accounts when the PC supports it. The CLI does not by default; opt in in config.toml and keep a fallback named:
[features]
prefer_mxc = true
[windows]
sandbox = "elevated"CopiedCLI 0.162.0 and later can test MXC for one command without changing anything. From a project folder in PowerShell, this should print MXC_OK and then 0:
codex -c windows.sandbox=mxc sandbox --include-managed-config --permission-profile :workspace -- cmd.exe /d /c echo MXC_OK
$LASTEXITCODECopiedOne MXC difference to plan for: “Remaining child processes stop when the foreground command exits,” so OpenAI says to test any workflow that relies on a detached development server. OpenAI’s security page prints the test command as codex sandbox windows …; the 0.171.0 CLI picks the platform itself and takes the command after --, as above.
Old settings, the shell, and removing it
- Older guides enable the sandbox with
experimental_windows_sandbox = trueorelevated_windows_sandbox = trueunder[features]. Both flags are marked removed in 0.171.0’s source; Codex still reads them asunelevatedandelevatedwhen[windows] sandboxis not set, and sandbox setup replaces them with that key. - Natively, Codex runs commands in PowerShell 7 (
pwsh) when it can find it, otherwise Windows PowerShell, andcmd.exeas the last resort. PowerShell installed from the Microsoft Store is the exception: a comment in Codex’s shell code says Store PowerShell “cannot run under MXC and can be inaccessible to the elevated sandbox account”, and for the sandbox the code looks for a PowerShell installed some other way. - To remove the legacy sandbox’s machine-wide accounts and network rules, stop the apps using it and run
codex sandbox uninstallas administrator. It leaves%USERPROFILE%\.codexin place.
Codex inside WSL2
From an administrator PowerShell, install WSL and its default distribution and open a shell in it; then, inside Linux, install Codex with the Linux script, per OpenAI’s WSL page:
# PowerShell, as administrator
wsl --install
wsl
# inside WSL
curl -fsSL https://chatgpt.com/codex/install.sh | sh
codexCopiedThe restart, the BIOS virtualization setting and systemd are covered in installing WSL2. Check the distribution is on version 2 with wsl -l -v: on WSL1, Codex refuses sandboxed commands, because the Linux sandbox moved to bubblewrap in 0.115 and WSL1 cannot create the user namespaces it needs. WSL2 “follows the normal Linux bubblewrap path”, so the Linux warnings apply there, and each bubblewrap warning and its fix has its own page, including converting a distribution from WSL1.
A CLI inside WSL keeps its settings, sign-in and history in the Linux ~/.codex, separate from the Windows app and a Windows CLI, which share %USERPROFILE%\.codex. To make WSL use the Windows folder, add this to ~/.bashrc or ~/.zshrc in WSL:
export CODEX_HOME=/mnt/c/Users/<windows-user>/.codexCopiedThe desktop app and the VS Code extension
The ChatGPT desktop app, which now holds Codex, installs from the Microsoft Store or with winget install --id 9PLM9XGG6VKS -s msstore, and codex app in the CLI opens it, or its installer if it is missing. The Windows-specific points in its app docs:
- Sandbox protection applies once you “select Ask for approval beneath the composer before sending messages to Codex.”
- For commands that need administrator rights, start the app itself with Run as administrator; the agent inherits that level.
- Without Git installed on Windows itself, some app features do not work, the review panel among them; install it with
winget install --id Git.Git. Git is not detected for projects opened through\\wsl$\. - The integrated terminal (PowerShell, Command Prompt, Git Bash or WSL) is set separately from where the agent runs.
Platforms, plans and the move into the ChatGPT app are in the Codex app guide.
The VS Code extension (openai.chatgpt, also for Cursor and Windsurf) runs natively unless you open the folder in WSL, as in the table above. OpenAI’s settings page still lists chatgpt.runCodexInWindowsSubsystemForLinux for this, but the extension itself, since version 26.1106.51428, describes that setting as “Deprecated. To run Codex in WSL, reopen your folder using the Microsoft WSL extension.” If the extension installs but never responds, OpenAI’s docs point to missing C++ build tools, which some of its native dependencies need, then a full restart of VS Code:
winget install --id Microsoft.VisualStudio.2022.BuildTools -eCopiedThe Microsoft Visual C++ Redistributable (x64) is the other piece the docs name. If it instead says “Codex could not start” on 26.1021.22027 (pre-release 26.51021.22027), that is a startup bug OpenAI fixed on November 11: update to 26.1106.51428 or later and reload the window. If the extension in a WSL window cannot find codex, run which codex in WSL and install the CLI there if it is missing. The extension’s settings and its WSL route in full are in the Codex VS Code extension guide.
Where Codex keeps its files on Windows
| What | Where |
|---|---|
Settings | %USERPROFILE%\.codex\config.toml |
Sign-in (default file store) | %USERPROFILE%\.codex\auth.json |
Sandbox log | %USERPROFILE%\.codex\.sandbox\sandbox.log |
The codex.exe on your PATH (script install) | %LOCALAPPDATA%\Programs\OpenAI\Codex\bin |
Installed releases (script install) | %USERPROFILE%\.codex\packages\standalone |
Administrator policy | %ProgramData%\OpenAI\Codex\requirements.toml |
Codex inside WSL | ~/.codex in the Linux home |
Setting CODEX_HOME moves everything listed under .codex. The desktop app uses the same folder as a native CLI. The settings file’s keys, layers and precedence are in the config.toml guide.
Errors Windows users hit
Recent releases have carried a steady run of Windows sandbox fixes: 0.169.0 fixed handling of quoted cmd.exe paths and of PowerShell sessions whose working directory has an unreadable parent, and 0.170.0 fixed “Windows file replacement, sandbox permission preservation, and runtime registration recovery.” Check codex --version against the releases page before debugging further.
“running scripts is disabled on this system”
PowerShell’s execution policy is blocking a script; OpenAI’s example is npm.ps1 cannot be loaded because running scripts is disabled on this system. With no policy set, Windows client editions run as Restricted. The docs’ fix is Set-ExecutionPolicy -ExecutionPolicy RemoteSigned, but without -Scope that changes the machine-wide policy, which Microsoft’s page says needs an administrator PowerShell. For your account only:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserCopied“start the Windows daemon from a non-elevated terminal”
The full line ends “shared clients must not inherit administrator privileges”. The CLI normally talks to a shared background server, which an OpenAI engineer describes as running “with your (non-elevated) user permissions”, and the daemon’s README says it needs a non-elevated terminal. Users met this line in September when they started Codex 0.157.0 from an administrator terminal. Since 0.161.0, whose changelog says “Elevated Windows terminal sessions can start using an embedded server”, Codex started as administrator runs without the shared server and shows a warning instead of failing; the line still appears if you run codex app-server daemon start or restart as administrator. On an older version, update, or use the workaround the same engineer gave:
codex --no-daemonCopiedIt runs that session “without the shared background server”, so background work and the other sessions’ shared view are not available to it, as in an administrator terminal on current versions.
“Couldn’t set up your sandbox with Administrator permissions”
The elevated setup failed, and the CLI offers Try setting up admin sandbox again or Use Codex with non-admin sandbox. OpenAI lists the usual causes: the UAC prompt was declined, or the PC does not allow creating local users or groups, changing firewall rules or granting the sandbox users the logon rights they need. On a company laptop, ask IT whether it allows those steps; where policy permits the non-admin sandbox, it keeps you working meanwhile.
Windows error 1385
Sandboxed commands fail with 1385 when “Windows is denying the logon type the sandbox user needs in order to start the command”: usually, setup created the sandbox users but policy will not let them start a process. Ask IT whether the device policy grants those users the logon rights; until it does, use unelevated.
Sandbox setup fails with error 32, or “setup refresh had errors”
In October, after the Windows desktop app updated to 26.1002.51308, many users reported every command failing with helper_unknown_error: setup refresh had errors and Windows error 32, a sharing violation, in the sandbox log (#51601, still open, with no reply from OpenAI there). The CLI’s 0.163.0 changelog of October 15 lists #51822, “Avoid sharing violations when repairing Windows runtime ACLs”; OpenAI has not said on the issue that this is the fix, but it is a reason to update the app or the CLI before anything else. For a sandbox that worked and then stopped, after moving a repository or changing permissions or policy, OpenAI’s steps are to restart Codex, run the setup again, use unelevated as a temporary fallback, and send sandbox.log if it persists, never the contents of .sandbox-secrets.
A warning that folders are writable by Everyone
Windows permissions on the folders Codex names are too broad for the sandbox to protect them. Remove write access for Everyone where that is appropriate, then restart Codex or run the setup again.
Console windows keep flashing open
From 0.157.0 in September, Codex on Windows opened stray console windows during requests. An OpenAI engineer said 0.159.2 “should take care of this problem”, and that the background server has to be updated too, which normally happens on its own and can be forced with /daemon in a session.
Shift+Enter does not add a new line
In an MSYS2 mintty terminal, Shift+Enter and Ctrl+J can reach Codex as Ctrl+Enter, so it cannot tell them apart. OpenAI’s reply is Alt+Enter, “a default Codex newline shortcut”.