App Proxy

Run Claude Code Behind Clash Verge: Terminal Proxy via Tun or Env Vars

Claude Code is a terminal client for Anthropic’s API. Browser OK, CLI connection timeout—usually the shell isn’t proxied, not a dead account.

Prefer Tun; else HTTPS_PROXY/HTTP_PROXY. Overview: Tun & AI. Site and Desktop are a different path: Claude.ai / Desktop. Siblings: Codex CLI, Aider.

Tun vs env vars

After enabling Tun, open a new shell—stale sessions keep the old route. Env vars point at 127.0.0.1:mixed-port; prefer session-only export before writing rc files (ports). A green system proxy in the GUI does not mean the shell has exported vars.

export HTTPS_PROXY=http://127.0.0.1:MIXED_PORT
export HTTP_PROXY=http://127.0.0.1:MIXED_PORT
export ALL_PROXY=socks5://127.0.0.1:MIXED_PORT
claude   # now the CLI traffic should appear in Connections

Prove it works

  1. Run one minimal request and watch the Connections page for hits.
  2. Timeouts → check nodes (latency); region reject → swap node.
  3. Re-check after CLI upgrades—they can reset proxy handling.

Split from Cursor/web

Don’t change three places at once without reading Connections. If sites load but the API fails, the issue is the terminal path, not the browser. Related: sites blocked, system proxy.

Stop

Fix Tun first (Tun, start failed) before piling on env vars. Builds: download center.

Get a stable proxy client first

Claude Code needs a proxy to reach Anthropic on a restricted network. Grab the latest Clash Verge Rev from the download center, then configure the terminal proxy below.