WSL2 Ubuntu 24.04 Setup Guide: Run Claude Code & Codex with QCode
Install Linux-native Node.js, Claude Code, and Codex CLI inside WSL2 Ubuntu 24.04 LTS on Windows 11, avoid Windows PATH leakage, and connect QCode with claude-opus-5-5 and gpt-6.2-sol.
Need an API key? Sign up →Endpoints & base URLs →
On This Page
Running Claude Code (claude), Codex CLI (codex), and OpenCode inside WSL2 (Ubuntu 24.04 LTS) gives Windows 11 developers native Linux tooling, full bubblewrap command sandboxing, and ext4 filesystem speed that is dramatically faster than cross-OS /mnt/c mounts.
Short answer: Confirm your distro runs on WSL 2 (wsl -l -v), install a Linux-native Node.js 22+ runtime plus Claude Code and Codex CLI inside Ubuntu 24.04, and write your cr_ key into Ubuntu's ~/.claude/settings.json (defaulting to claude-opus-5-5) and ~/.codex/config.toml (defaulting to gpt-6.2-sol).
| Tool | Config file inside WSL2 | QCode Base URL | Recommended default |
|---|---|---|---|
| Claude Code | ~/.claude/settings.json |
https://api.qcode.cc/api |
claude-opus-5-5 |
| Codex CLI | ~/.codex/config.toml |
https://api.qcode.cc/openai (wire_api = "responses") |
gpt-6.2-sol |
| OpenCode | ~/.config/opencode/opencode.json |
Anthropic /api · OpenAI /openai/v1 · Gemini /gemini/v1beta |
All three families |
Checked on 2026-12-04 · Ubuntu 24.04.5 LTS (WSL2) · Claude Code 2.1.x · Codex CLI 0.174.x · Windows 11
- Run
wsl -l -vin Windows PowerShell and confirm theVERSIONcolumn forUbuntu-24.04reads2(if it reads1, runwsl --set-version Ubuntu-24.04 2— WSL 1 breaks Claude Code's native binary and Codex'sbubblewrapsandbox) - Keep Git repositories inside Ubuntu's own
ext4filesystem (for example~/projects/...), not under/mnt/c/... - Copy your
cr_API key from the QCode Dashboard (no account yet? Sign up and pick a monthly plan or a 7-day Pay-as-you-go Pack) - Remember: Windows environment variables are not exported into WSL2 automatically — save your configs inside Ubuntu's
~/home directory
Prerequisites: Install or Open Ubuntu 24.04 (WSL2)¶
Pick your network environment:
Outside Mainland China
- If WSL2 is not installed yet, open an elevated PowerShell window and run
wsl --install -d Ubuntu-24.04, reboot if prompted, and create your Linux user. - Open Windows Terminal and pick Ubuntu 24.04 from the tab dropdown.
- Use the default npm registry and
https://api.qcode.ccingress domain (https://us.qcode.ccis also available for North America and Europe).
Mainland China
- Install Ubuntu 24.04 LTS via
wsl --install -d Ubuntu-24.04or directly from the Microsoft Store. - Inside Ubuntu, append
--registry=https://registry.npmmirror.comwhen installing global npm packages ifregistry.npmjs.orgis slow. - You can use either
https://api.qcode.ccor the Asia ingress domainhttps://asia.qcode.ccwith the exact samecr_key.
Step-by-Step Setup (4 Steps)¶
Verify Ubuntu 24.04 and a Linux-native Node.js binary¶
Open an Ubuntu-24.04 tab in Windows Terminal, create a project folder on the native Linux filesystem, and check your distro version and node path:
mkdir -p ~/projects/demo && cd ~/projects/demo
lsb_release -ds
which node && node -v
Check two lines: ① lsb_release -ds prints Ubuntu 24.04.x LTS; ② which node resolves to a Linux path such as /usr/local/bin/node, /usr/bin/node, or ~/.nvm/... — never /mnt/c/Program Files/nodejs/node (calling Windows Node from WSL installs .cmd shims and breaks Linux tool sandboxes).

Done right you will see: Ubuntu 24.04.x LTS, a Linux /usr/... or /home/... path for node on major version v20+, and a working directory under /home/<user>/projects/demo.
Stuck? which node shows /mnt/c/Program Files/nodejs/node or not found
WSL2 appends your Windows PATH by default when no Linux Node binary is installed. Install Node.js 22 LTS directly inside Ubuntu (via nvm install 22 or the official Linux x64 archive), reopen the Ubuntu tab, and confirm which node points to Linux.
Install Claude Code and Codex CLI inside Ubuntu¶
Install both coding CLIs inside Ubuntu and verify their versions:
npm install -g @anthropic-ai/claude-code @openai/codex
claude --version
codex --version
(You can also install Claude Code with Anthropic's standalone Linux installer curl -fsSL https://claude.ai/install.sh | bash.)

Done right you will see: ① claude --version prints 2.1.x (Claude Code) and ② codex --version prints codex-cli 0.174.x (or newer) with no Exec format error.
Stuck? Exec format error or missing bwrap sandbox
Exec format error almost always means the distro is still on WSL 1. Run wsl -l -v in Windows PowerShell and upgrade with wsl --set-version Ubuntu-24.04 2. If Codex reports a missing bubblewrap binary on minimal Ubuntu images, run sudo apt-get update && sudo apt-get install -y bubblewrap.
Write ~/.claude/settings.json and ~/.codex/config.toml¶
Replace cr_your_key below with your QCode API key to configure Claude Code (claude-opus-5-5) and Codex CLI (gpt-6.2-sol) inside Ubuntu, locking permissions to 600:
mkdir -p ~/.claude ~/.codex
cat > ~/.claude/settings.json <<'EOF'
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.qcode.cc/api",
"ANTHROPIC_AUTH_TOKEN": "cr_your_key"
},
"model": "claude-opus-5-5"
}
EOF
cat > ~/.codex/config.toml <<'EOF'
model_provider = "qcode"
model = "gpt-6.2-sol"
[model_providers.qcode]
name = "QCode"
base_url = "https://api.qcode.cc/openai"
env_key = "QCODE_API_KEY"
wire_api = "responses"
EOF
grep -qxF 'export QCODE_API_KEY="cr_your_key"' ~/.bashrc || echo 'export QCODE_API_KEY="cr_your_key"' >> ~/.bashrc
source ~/.bashrc
chmod 600 ~/.claude/settings.json ~/.codex/config.toml
Pay attention to the two URL rules: ① Claude Code's ANTHROPIC_BASE_URL stops at /api (no /v1); ② Codex CLI uses wire_api = "responses" and stops at /openai (no /v1).

Done right you will see: valid ~/.claude/settings.json and ~/.codex/config.toml files in your Ubuntu home folder, and echo ${#QCODE_API_KEY} printing a length greater than 10.
Verify gateway connectivity from WSL2 with curl¶
Test HTTPS reachability from WSL2 to api.qcode.cc with curl, then launch claude or codex:
# 1. Unauthenticated reachability probe (HTTP 401 + JSON invalid_api_key proves DNS & TLS reach QCode)
curl -i -s https://api.qcode.cc/v1/models | head -n 12
# 2. Authenticated models check (prints 200 when your active cr_ key is loaded)
curl -s -o /dev/null -w "%{http_code}\n" -H "Authorization: Bearer $QCODE_API_KEY" https://api.qcode.cc/v1/models

Done right you will see: the unauthenticated probe immediately returns HTTP/2 401 with content-type: application/json (invalid_api_key), and the authenticated check prints 200. Type claude or codex in your project directory to start coding.
Stuck? curl fails with Could not resolve host inside WSL2
VPN or Wi-Fi transitions on Windows can leave WSL2's NAT /etc/resolv.conf stale. On Windows 11 23H2+, add networkingMode=mirrored under [wsl2] in %USERPROFILE%\.wslconfig, then run wsl --shutdown in PowerShell and reopen Ubuntu.
All done¶
Claude Code (claude-opus-5-5) and Codex CLI (gpt-6.2-sol) are now running natively inside WSL2 Ubuntu 24.04 on QCode. Next steps:
VS Code Remote-WSL & Image Clipboard Tips¶
- Pair with VS Code Remote-WSL: Install Microsoft's WSL extension (
ms-vscode-remote.remote-wsl) in Windows VS Code, then runcode .inside your Ubuntu project folder. The UI runs natively on Windows while the extension host and integrated terminal run inside Ubuntu 24.04, automatically reading~/.claude/settings.json. - Pasting screenshots into Claude Code on WSL: Press
Alt + V(rather thanCtrl + V) to paste clipboard images into a WSL Claude Code session; installsudo apt-get install -y xclip wl-clipboardif prompted. - Parallel Git worktrees: Combine your WSL2
ext4repo withtmux, Orca, or Paseo to run parallel agents on one sharedcr_key.
Get started with QCode
One API key for Claude Code, Codex and more — billed per token, per-model prices on qcode.cc/models