# WSL2 Ubuntu 24.04 Setup Guide: Run Claude Code & Codex with QCode

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



- **Applies to**: Windows 10 (2004+) / Windows 11 (64-bit with WSL2 enabled)
- **Distro**: Ubuntu 24.04 LTS (WSL 2 kernel)
- **Screenshots updated**: 2026-12
- **Time needed**: ~10 minutes
- **You will need**: One `cr_` API key from QCode



- Run `wsl -l -v` in Windows PowerShell and confirm the `VERSION` column for `Ubuntu-24.04` reads **`2`** (if it reads `1`, run `wsl --set-version Ubuntu-24.04 2` — WSL 1 breaks Claude Code's native binary and Codex's `bubblewrap` sandbox)
- Keep Git repositories inside Ubuntu's own `ext4` filesystem (for example `~/projects/...`), not under `/mnt/c/...`
- Copy your `cr_` API key from the [QCode Dashboard](https://qcode.cc/en/dashboard) (no account yet? [Sign up](https://qcode.cc/en/auth/sign-up?utm_source=docs.qcode.cc&utm_medium=tut_before&utm_campaign=knowledge_base&src=docs-wsl-ubuntu-before) and pick a [monthly plan](https://qcode.cc/en/pricing?utm_source=docs.qcode.cc&utm_medium=tut_before&utm_campaign=knowledge_base&src=docs-wsl-ubuntu-before) or a 7-day [Pay-as-you-go Pack](https://qcode.cc/en/pay-as-you-go?utm_source=docs.qcode.cc&utm_medium=tut_before&utm_campaign=knowledge_base&src=docs-wsl-ubuntu-before))
- 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**

1. 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.
2. Open **Windows Terminal** and pick **Ubuntu 24.04** from the tab dropdown.
3. Use the default npm registry and `https://api.qcode.cc` ingress domain (`https://us.qcode.cc` is also available for North America and Europe).


**Mainland China**

1. Install **Ubuntu 24.04 LTS** via `wsl --install -d Ubuntu-24.04` or directly from the Microsoft Store.
2. Inside Ubuntu, append `--registry=https://registry.npmmirror.com` when installing global npm packages if `registry.npmjs.org` is slow.
3. You can use either `https://api.qcode.cc` or the Asia ingress domain `https://asia.qcode.cc` with the exact same `cr_` 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:

```bash
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).

![Ubuntu 24.04 tab inside Windows Terminal verifying lsb_release -ds, Linux-native /usr/local/bin/node v22.14.0, and the ~/projects/demo directory](https://docs.qcode.cc/static/images/tut/wsl-ubuntu/202612/en/01-wsl-env-check.webp)


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:

```bash
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`.)

![Verifying installed Claude Code and Codex CLI versions inside the Ubuntu 24.04 terminal](https://docs.qcode.cc/static/images/tut/wsl-ubuntu/202612/en/02-install-clis.webp)


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`:

```bash
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`).

![Inspecting ~/.claude/settings.json (claude-opus-5-5 with masked key) and ~/.codex/config.toml (gpt-6.2-sol with wire_api = responses) in Ubuntu 24.04](https://docs.qcode.cc/static/images/tut/wsl-ubuntu/202612/en/03-write-configs.webp)


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`:

```bash
# 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
```

![Running curl against https://api.qcode.cc/v1/models inside Ubuntu 24.04 to confirm HTTPS and JSON gateway connectivity](https://docs.qcode.cc/static/images/tut/wsl-ubuntu/202612/en/04-verify-gateway.webp)


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:

- [Claude Code Complete Tutorial](/docs/getting-started/claude-code-tutorial)
- [Codex Complete Tutorial](/docs/ide/codex)
- [OpenCode Integration](/docs/ide/opencode)
- [Billing Description](/docs/reference/billing)


## 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 run `code .` 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 than `Ctrl + V`) to paste clipboard images into a WSL Claude Code session; install `sudo apt-get install -y xclip wl-clipboard` if prompted.
- **Parallel Git worktrees**: Combine your WSL2 `ext4` repo with `tmux`, [Orca](/docs/ide/orca), or [Paseo](/docs/ide/paseo) to run parallel agents on one shared `cr_` key.