Many users of Codex CLI encounter a mysterious error when running commands:
(code=3221225781, signal=null)
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.






