Many users of Codex CLI encounter a mysterious error when running commands:
(code=3221225781, signal=null). most recent error: codex app-server websocket closed (code=3221225781)
This can occur even if Node.js is correctly installed and the OpenAI API key is set properly. We investigated the issue and found a working solution. Below is a step-by-step guide.
Quick working answer: Download Visual C++ Redistributable for Visual Studio 2017–2026 (vc_redist.x64.exe) from Microsoft’s official page. Install it and restart your computer.
Check Node.js and Codex CLI Versions
First, ensure your environment meets Codex CLI requirements:
node –version
npm –version
codex –version
Codex CLI requires Node.js ≥16.
If you have an older version (e.g., 10.8.2), update Node.js from the official site.
After updating Node.js, reinstall Codex CLI:
npm uninstall -g @openai/codex
npm install -g @openai/codex
Set Up OpenAI API Key
Codex CLI requires an OpenAI API key for authorization. Get your key from https://platform.openai.com/account/api-keys.
In PowerShell, set the key for the current session:
$Env:OPENAI_API_KEY=”your_openai_api_key”
Check it:
echo $Env:OPENAI_API_KEY
Allow Script Execution in PowerShell
The error often occurs because PowerShell blocks script execution. Allow it for the current session:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Confirm with Y. This is safe since it only affects the current session.
Install Visual C++ Redistributable
The main cause of the 3221225781 error is the missing Microsoft Visual C++ libraries.
Download Visual C++ Redistributable for Visual Studio 2017–2026 (vc_redist.x64.exe) from Microsoft’s official page
Install it and restart your computer.
Test Codex CLI
After completing the steps, test the CLI:
codex exec “echo test”
The output should be: test. If there’s no output, try JSON mode:
codex exec –json “echo test”
After following these steps, Codex CLI runs correctly, the 3221225781 error disappears, and exec and run commands work properly.







The error code 3221225781 (hexadecimal 0xC0000135) indicates that a required System DLL was not found, which prevents the Codex extension’s backend process from starting. This is commonly caused by missing Microsoft Visual C++ runtime libraries on Windows.
GitHub
GitHub
+3
Recommended Fixes
1. Install/Update Visual C++ Redistributables: This is the most successful solution for this specific error.
2. Download the latest Microsoft Visual C++ Redistributable (X64 and X86) from official Microsoft pages.
3. Install the packages and restart your computer.
4. Verify if C:\Windows\System32\vcruntime140_1.dll is present after installation.
5. Disable WSL Mode: If you recently enabled WSL (Windows Subsystem for Linux) in the Codex settings, it may be causing the crash.
Navigate to %USERPROFILE%\.codex\.
6. Open .codex-global-state.json with a text editor.
Find “runCodexInWindowsSubsystemForLinux” and set it to false.
Save the file and restart VS Code.
Thanks!