-
Notifications
You must be signed in to change notification settings - Fork 2
Claude Code and Claude Code Router
I’ve recently been testing Claude Code and Claude Code Router across a variety of environments, including native Windows, WSL, and macOS. While the cross-platform capabilities are impressive, I encountered several hidden pitfalls—particularly when configuring the tools to operate behind strict corporate network proxies alongside local package managers like npm and Maven.
If you are running into connection timeouts or routing errors, here is how to debug your setup.
Run this command to ping your local router. (Make sure your router is actively running on port 3456 before testing).
export OPENROUTER_API_KEY="sk-123456"
curl -v POST http://localhost:3456/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-d '{
"model": "google/gemini-2.5-pro",
"messages": [{"role": "user", "content": "test"}]
}'If the local router fails, you need to check if your machine can reach the upstream provider directly. This bypasses your local router to test your outbound internet connection.
export OPENROUTER_API_KEY="sk-123456"
curl https://openrouter.ai/api/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-d '{
"model": "openai/gpt-5.2",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}'If those tests fail, your environment variables are likely clashing with your network setup. Walk through these steps:
-
Validate your config: Ensure your ~/.claude-code-router/config.json file is perfectly formatted JSON. A stray comma will break the router silently.
-
Assess your VPN/Proxy needs:
-
If you are on a standard connection or using a VPN that handles routing automatically at the system level, remove all http_proxy, https_proxy, all_proxy, and no_proxy environment variables.
-
If you are behind a strict corporate firewall that requires manual proxying, ensure those variables are explicitly set in your environment.
-
Configure the router proxy: If you require a proxy, you must also define it directly inside your ~/.claude-code-router/config.json. Add the line: "PROXY_URL": "http://127.0.0.1:7890/".
- The no_proxy Trap: If you set proxy variables, you must update your no_proxy environment variable to include localhost and 127.0.0.1. If you forget this, your terminal will try to route your localhost:3456 requests out to the internet, resulting in immediate connection failures.
(Note: I have personally fallen into the no_proxy trap twice. Especially in WSL, it is easy to forget that local traffic needs to be explicitly excluded from the global proxy rules!)
Created by Wenliang Zhang.