Windows WSL2 consistent API Errors

Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 6 comments · opened Mar 2, 2025 · closed May 7, 2025
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Issue overview

Hello, I have installed Claude code on my Windows Laptop using WSL following: https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview. I was able to get claude installed fine, no errors but I keep getting an API Error that I havent been able to decipher. My API Keys are created and I see them at https://console.anthropic.com/. Billing is set up as well. The error below is consistent on ALL calls including /login

Error:


 Tips for getting started:

 1. Run /init to create a CLAUDE.md file with instructions for Claude.
 2. Ask Claude questions about your codebase.
 3. Ask Claude to implement changes to your codebase.
  ⎿  API Error (Connection error.) · Retrying in 1 seconds… (attempt 1/10)
  ⎿  API Error (Connection error.) · Retrying in 1 seconds… (attempt 2/10)
  ⎿  API Error (Connection error.) · Retrying in 2 seconds… (attempt 3/10)
  ⎿  API Error (Connection error.) · Retrying in 4 seconds… (attempt 4/10)
  ⎿  API Error (Connection error.) · Retrying in 8 seconds… (attempt 5/10)
  ⎿  API Error (Connection error.) · Retrying in 16 seconds… (attempt 6/10)
  ⎿  API Error (Connection error.) · Retrying in 32 seconds… (attempt 7/10)
  ⎿  API Error (Connection error.) · Retrying in 32 seconds… (attempt 8/10)
  ⎿  API Error (Connection error.) · Retrying in 32 seconds… (attempt 9/10)

System configuration


# wsl --version
WSL version: 2.4.11.0
Kernel version: 5.15.167.4-1
WSLg version: 1.0.65
MSRDC version: 1.2.5716
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.22631.4890

# uname -a
Linux NAME-REDACTED 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

# nvm --version
0.40.1

# node --version
v22.14.0

#npm --version
10.9.2

#claude --version
0.2.29 (Claude Code)

Fixes tried / Verifications done

  • Reinstall Claude multiple times.
  • Deleted API Keys & recreated them multiple times.
  • Ruled out network issue as curl to console.anthropic.com works just fine.
  • Verified claude.json to see hasCompletedOnboarding:true & hasTrustDialogAccepted:true & customerApiKeyResponses:approved.
  • Verified System status was UP: https://status.anthropic.com/
  • Used sudo npm install instead or npm install.

View original on GitHub ↗

6 Comments

sumukhballal · 1 year ago

Interestingly enough when I try to hit the API directly from the shell, it does seem to be at least getting a response, which rules out a network issue from the host.

Request:

curl -vv https://api.anthropic.com/v1/messages --header "x-api-key: REDACTED"  --header "anthropic-version: 2023-06-01" --header "content-type: application/json" --data '{
    "model": "claude-3-7-sonnet-20250219",
    "max_tokens": 1024,
    "messages": [
        {"role": "user", "content": "Hello, world"}
    ]
}'

Response:

{"type":"error","error":{"type":"invalid_request_error","message":"system: This API key is only authorized for use with Claude Code and cannot be used for other API requests."}}
sumukhballal · 1 year ago

Running /doctor gives me

│
│ ✓ npm permissions: OK                                                                                                                                                                                      │
│                                                                                                                                                                                                            │
│ Your installation is healthy and ready for auto-updates.     
ShawnFumo · 1 year ago

Does it do it every time? I've seen it happen every once in a while in my WSL, but it hasn't stopped the app from working correctly.

bcherny collaborator · 1 year ago

This likely is unrelated to WSL. Please update to the latest version and re-open if this is still happening.

RediAdAstra · 1 year ago

Happening for me.

`~/systempromptlibrary$ claude
╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
│ cwd: /home/adastra/systempromptlibrary │
╰───────────────────────────────────────────────────╯

Tips for getting started:

  1. Run /init to create a CLAUDE.md file with instructions for Claude
  2. Use Claude to help with file analysis, editing, bash commands and git
  3. Be as specific as you would with another engineer for the best results
/init is analyzing your codebase…

⎿ API Error (Request timed out.) · Retrying in 1 seconds… (attempt 1/10)
⎿ API Error (Request timed out.) · Retrying in 1 seconds… (attempt 2/10)
⎿ API Error (Request timed out.) · Retrying in 2 seconds… (attempt 3/10)
⎿ API Error (Request timed out.) · Retrying in 4 seconds… (attempt 4/10)
⎿ API Error (Request timed out.) · Retrying in 10 seconds… (attempt 5/10)
⎿ API Error (Request timed out.) · Retrying in 19 seconds… (attempt 6/10)
⎿ API Error (Request timed out.) · Retrying in 36 seconds… (attempt 7/10)
⎿ API Error (Request timed out.) · Retrying in 36 seconds… (attempt 8/10)
⎿ API Error (Request timed out.) · Retrying in 39 seconds… (attempt 9/10)
⎿ API Error (Request timed out.) · Retrying in 39 seconds… (attempt 10/10)
⎿  API Error: Request timed out.
`

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.