How to Run OpenAI Codex in Windows with WSL

A detailed guide to running OpenAI Codex on Windows using WSL, covering WSL install, Node.js setup, Codex CLI installation, troubleshooting, and integrating API testing with Apidog.

Ashley Goolam

Ashley Goolam

28 January 2026

How to Run OpenAI Codex in Windows with WSL

Getting OpenAI Codex running smoothly on Windows is not plug-and-play due to native support limitations. The preferred and most reliable way to run Codex on Windows with WSL (Windows Subsystem for Linux) is by creating a Linux-like environment that matches Codex’s primary supported platform: Linux. This guide walks you through a practical, CLI-first setup with WSL, plus tips for editors like VS Code, authentication, common pitfalls, and real-world workflows using Codex CLI.

button

Why Use WSL for Codex on Windows?

Codex CLI is officially supported for macOS and Linux environments. While Windows PowerShell support exists, it’s experimental and unreliable for many workflows. The official docs explicitly recommend using WSL for the best experience.

WSL gives you:

This makes debug, tests, module scripts, permissions, and context handling behave exactly as the model expects.

Codex CLI

Step 1: Install WSL

Assuming you’re on Windows 10 or 11, open PowerShell as an administrator and install WSL with your preferred distro (Ubuntu is recommended):

wsl --install -d Ubuntu

After installation, reboot or let the installer finish. Then launch the Ubuntu distribution with:

wsl

To confirm WSL is active:

echo $WSL_DISTRO_NAME

This should print the distribution name (e.g., Ubuntu). Working inside WSL ensures Linux-compatible behavior and avoids sandbox quirks in native Windows.

view the windows distro name

Step 2: Install Linux Toolchain and Node.js

Once inside your WSL shell, you’ll need the Node.js toolchain before installing Codex CLI.

If you use nvm (Node Version Manager), install it first:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
source ~/.bashrc
nvm install 22

This gives you Node.js 22 (long-term support). Verify versions:

node --version
npm --version

These commands should return modern versions compatible with Codex CLI.

Verify node and npm Installation

Step 3: Install Codex CLI

Now that Node.js is ready, install the Codex CLI globally:

npm install -g @openai/codex

After installation, you should be able to confirm the installation with:

codex --version

If the output shows a valid CLI version, you’re good to go. This CLI is the same one used on macOS and Linux — meaning no Windows-specific compatibility layer is needed.

check codex version in wsl

Step 4: Authenticate Codex

Codex requires authentication to access the models. In WSL, you can export your OpenAI API key if you prefer API key auth:

echo 'export OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx' >> ~/.bashrc
source ~/.bashrc

Alternatively, running codex interactively will prompt you to sign in via a browser, which works even inside WSL by opening the default Windows browser. If the browser doesn’t open automatically, you can follow the printed link manually.

Authenticate codex cli

Step 5: Run Codex CLI

Inside your WSL shell, navigate to your project directory. It’s best to keep your code inside the Linux filesystem, e.g., ~/code/myproject, for faster I/O and cleaner path semantics. Avoid using /mnt/c/... for major operations because performance and symlinks can degrade.

# Navigate to root directory
mkdir -p ~/code && cd ~/code

# Clone your repository
git clone https://github.com/your/repo.git
cd repo

# Launch Codex with:
codex

If you want Windows access to files, head over to \wsl$\Ubuntu\home<user> in your Explorer. This opens the interactive terminal UI. From here, you can ask Codex to:

All while preserving Unix semantics and shell capabilities that align with typical developer workflows.

opening codex in wsl

To edit and debug your project while using Codex in WSL:

  1. Install VS Code on Windows.
  2. Add the Remote - WSL extension.
  3. From a WSL terminal, run:
cd ~/code/myproject
code .

VS Code will open in “WSL mode” with a green status bar indicating WSL: <distro>. All integrated terminals will be Linux shells — perfect for Codex workflows. (OpenAI Developers)

You can also set the Codex extension to use WSL by enabling:

"chatgpt.runCodexInWindowsSubsystemForLinux": true

in your IDE settings, ensuring the extension runs the CLI inside WSL.

Best Practices for Codex on WSL

1. Keep Code in Linux FS:

Store repositories in your WSL home directory (~/code/...) instead of /mnt/c/.... This avoids slow file access, permission confusion, and symlink issues.

2. Update WSL When Needed:

If performance seems slow or tools hang, try updating WSL and rebooting:

wsl --update
wsl --shutdown

This refreshes kernels and binaries.

3. Wrap with PowerShell Shortcuts:

Some community scripts set up wrappers so that you can call codex from any Windows path by forwarding the call to WSL. This is optional but useful if you want to run Codex from PowerShell while still executing inside WSL.

Troubleshooting Common Issues

Codex Doesn’t Launch in WSL: Verify the binary exists and is on PATH

which codex || echo "codex not found"

If missing, reinstall:

npm install -g @openai/codex

Also check WSL distro updates and Node installation.

Slow File System Access: If your codebase is under /mnt/c/..., Git, Docker, and test runners may run slowly due to cross-filesystem overhead. Move the repo into your Linux home directory.

Authentication Fails in WSL: Sometimes the login prompt may not open a browser from inside WSL. In that case, copy the provided URL and open it manually in your Windows browser.

How Apidog Works in API-Centric Projects

Running Codex in WSL allows you to generate API controllers, services, and tests rapidly. But generating code is only half the story — you also need API behavior verification.

Apidog excels in API validation:

When combined with Codex for endpoint generation, Apidog ensures that your API logic actually meets runtime expectations. Start with Apidog for free to validate real HTTP behavior as you code.

API testing with Apidog
API testing with Apidog
button

Frequently Asked Questions

Q1. Is Windows native support sufficient for Codex without WSL?
Windows native support is experimental and unreliable. The best experience comes from running Codex in WSL due to Linux compatibility.

Q2. Do I need a paid plan to run Codex?
Yes — Codex requires a ChatGPT Plus, Pro, Business, or Enterprise subscription. Free tiers may not grant model access.

Q3. Can I use WSL 1 instead of WSL 2?
WSL 2 is strongly recommended because it provides a real Linux kernel and better filesystem semantics. WSL 1 may work but with degraded performance.

Q4. Can I run multiple Codex sessions concurrently?
Yes, in WSL you can open multiple terminals and run independent Codex sessions as long as you have sufficient quota and environment resources.

Q5. Will Codex treat Windows paths differently?
Codex sees Linux paths inside WSL normally — avoid Windows paths (like /mnt/...) for core operations to prevent confusion.

Conclusion

Running OpenAI Codex on Windows with WSL gives you the best blend of compatibility, performance, and stability. WSL delivers a real Linux environment that works natively with Codex CLI tooling, avoids sandbox quirks, and aligns with development workflows used in production. Combine this setup with tools like Apidog to validate your API behavior and ensure your generated code works exactly as expected.

button

Explore more

Top 10 Stablecoins Payment APIs in 2026

Top 10 Stablecoins Payment APIs in 2026

Explore the top 10 Stablecoins Payment APIs in 2026 for seamless integration, fast settlements, and low fees. Developers rely on Stablecoins Payment APIs from providers like Circle, Stripe, and Bridge to handle USDC, USDT, and more.

6 February 2026

Top 10 Prediction Market APIs in 2026

Top 10 Prediction Market APIs in 2026

Explore the leading Prediction Market APIs dominating 2026, from Polymarket to Kalshi. Learn key features and integrations to boost your applications.

6 February 2026

Top 10 Influencer Marketing APIs in 2026

Top 10 Influencer Marketing APIs in 2026

Explore the top 10 Influencer Marketing APIs in 2026 powering precise creator discovery, real-time analytics, fraud detection, and campaign automation.

6 February 2026

Practice API Design-first in Apidog

Discover an easier way to build and use APIs