[BUG]
Resolved 💬 47 comments Opened Mar 29, 2025 by lincbal4 Closed Feb 1, 2026
💡 Likely answer: A maintainer (dhollman, contributor)
responded on this thread — see the highlighted reply below.
Here's the updated bug report with the Claude CLI version:
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude Code version: 0.2.56
- Operating System: Windows 11 with Ubuntu WSL
- Terminal: VS Code with Ubuntu (WSL) terminal
Bug Description
Persistent "API Error: Connection error" when using Claude Code CLI in WSL terminal through VS Code. This issue has recently increased in frequency - previously it occurred rarely or not at all.
Steps to Reproduce
- Open VS Code and select Ubuntu (WSL) terminal from dropdown
- Run any Claude Code command (e.g., asking a question)
- Observe "API Error: Connection error" message
- Notice automatic retry attempts also fail with the same error
Expected Behavior
Claude Code should connect to the Anthropic API and process commands successfully.
Actual Behavior
Commands fail with "API Error: Connection error" message, followed by retry attempts that also fail:
⎿ API Error: Connection error.
⎿ API Error (Connection error.) · Retrying in 1 seconds… (attempt 1/10)
Additional Context
- All required domains (registry.npmjs.org, api.anthropic.com, sentry.io, statsig.anthropic.com, statsig.com) are accessible from WSL as verified by curl tests
- Network connectivity to all domains confirmed working
- API key appears to be set (authentication would be a different error message)
- Issue occurs specifically in VS Code's WSL terminal environment
- Problem has increased in frequency recently, suggesting a possible change in environment or API behavior
47 Comments
Additional Context (Update)
After further investigation, I've discovered that the "API Error: Connection error" is being caused by Cloudflare's security measures. A verbose curl test to claude.ai revealed:
This shows that Cloudflare is presenting a browser challenge ("Just a moment..." page) instead of allowing direct API access. This explains why Claude Code CLI is unable to complete requests - it doesn't have the capability to solve these Cloudflare challenges like a browser can.
Key observations:
This appears to be an issue that would need to be addressed in Claude Code itself, possibly by implementing browser-like headers or other techniques to properly handle Cloudflare challenges.
Is this an issue Claude Code needs to fix on their end?
Thanks @lincbal4 . I've been experiencing this issue non stop for the last couple of days (0.2.57 (Claude Code), though i think it started a version or 2 before). Mine occurs from any terminal (I run Claude Code almost exclusively from iTerm)
I'm currently experiencing the same thing, Cloudflare's JavaScript challenge is kicking in
This error started for me this morning and has lasted about 3 hours so far. Is there a resolution yet?
Same here, same thing - curl -v https://claude.ai gets me a Cloudflare challenge..
Same here if I use mobile hotspot. VPN solved it for me now ¯\_(ツ)_/¯
I am having the same issue, curl -v https://claude.ai from WSL results in a challange. This is new behavior over the last week.
I seem to be running into this right now as well. Seeing the same "HTTP/2 403". Pretty stuck at this point!
EDIT: I tried turning off the VPN software on my laptop, and that resolved the issue.
I have the same problem, and it seems to have something to do with the limitations or restrictions when we reach the limits of the max plan.
When I start something in a fresh 5h time range, then everything works good. But after some heavy use, I got very often this API error. The only thing which works is to wait for a while (hour or more) and then it works again.
In Claude code, I don't have any warnings about that I reached my limit or the context is low. Everything seems to be fine, but only I get a lot of API errors with up to 10 attempts.
For me, it has nothing to do with a VPN or a bad internet connection.
claude --version
1.0.3 (Claude Code)
<img width="927" alt="Image" src="https://github.com/user-attachments/assets/06e9a86a-7d30-4384-911c-0357c1b5154e" />
same here same error how to fix it ?
1.0.6 (Claude Code)
It is unusable. Spend money for that and i cannot use it. Rubbish :(
I have the same error, though am interested to hear whether anyone else was able to resolve by switching from the api to the max plan looking at the comment from @udiedrichsen
I'm on the api at the moment, but would consider the max plan if it would resolve..
I am on the Max plan, and it happens mostly for me when I reach my limit (besides this plan).
Yes exactly @udiedrichsen - I think once you reach the limit it might switch over to the api (as per https://support.anthropic.com/en/articles/11145838-using-claude-code-with-your-max-plan) and that's why you dont see it typically. Perhaps I'm just hoping! Would be interested to see whether anyone else sees the same on the max plan or whether this is limited to when cc is using the api.
Yes, and I'm on the big Max plan, and it's pretty hard to reach it, so it's not a big deal from my point of view. If you switch to Sonnet you avoid this problem.
I'm on 20x Max and have been encountering this issue intermittently for the past 36-ish hours. Model selection auto and Sonnet both run into this. I've attempted to reproduce with the curl command as stated above, but have been unsuccessful. The true sporadic nature of this leads me to believe this is on the Anthropic side.
Claude max user here and this is very, very annoying.
I was excited to try Claude Code and even invested in the API, but unfortunately I haven’t been able to get it working due to this very error. I went as far as setting up a MITM proxy to diagnose the issue (since the default Claude Code logs are not very helpful), and that's how I discovered that I am consistently hitting a 403 wall with Cloudflare.
It appears this may be caused by a misconfiguration — Cloudflare’s API Shield is designed specifically to prevent browser-based challenges for API endpoints. I would strongly encourage the team to look into this, as it seems like a straightforward fix.
It’s disappointing to see such a basic issue affect paying customers for months without resolution. This has made my first experience with Anthropic quite negative. I was thinking about investing into Max, but the very thought that anytime I can be left without access and my hundred bucks as well scares me.
I have the same issue with WSL, I found the cause it's because of Comodo firewall blocking DNS and ARP for WSL.
As soon as I disable the firewall entirely, Claude Code works just fine and there is no more API Error.
Edit: The rules are to be added in application for Windows Operating System, add and allow all IP Claude Code is trying to connect on port 443
I'm encountering the same "API Error (Connection error.)" issue. In my case, it only happens when Claude Code attempts to generate or edit a longer piece of code using the "Write", "Edit", or "MultiEdit" tools. This has unfortunately made Claude Code nearly unusable for me.
This is pretty terrible UX. This should at least tell us what is going on, rather than just erroring, even if it is just the usage limit kicking in.
Same issue in mac with claude pro plan. I noticed that it sometimes works when I stop docker. Is there a solution for this?
After testing for hours, just confirmed that the same problem caused by the Cloudflare Shield when connecting to "console.anthropic.com" [Claude Code version 1.0.30]. Seems no solution right now. Why this happens when the CLI tools produced by Anthropics itself using it's own API. Seems unreasonable. (Well, claude.ai agrees with me when I try to investigated what's going on)
!Image
Having the same issue
I have the same issue, but it seems after removing references to larger files in my CLAUDE.md file, the issue happens only sporadic, wehereas before the
API Erroroccured often.!Image
same issue here, just bought subscription a day ago. can we do something about this already?
Is the Cloudflare Shield issue expected? Why has there been no response for so long? It seems to me that this is a problem the official team can easily solve. Also, I found that this issue only occurs on the console, not the API. Once I successfully log in, Cloudflare Shield never triggers again, which indicates that the problem is specific to the console domain.
i resolve this issue by reinstalling docker desktop, in my case the error is not caused by the claude team, its something related to docker networking. at first, i try to uninstall docker and all related to it but it fail. then i installed docker again and it worked.
im using wsl in windows and if you can't run
sudo apt updatein your terminal, than it's related to your network not claude error. try reinstall docker if that's the caseHi, thanks for your solution, but that's not my case. I am using macOS.
https://github.com/anthropics/claude-code/issues/653#issuecomment-3018929302
Just reinstalling docker desktop fixed my issue, thank you :)
If you have docker desktop installed, it may be running in background even if you quit it
Run this in terminal:
killall "Docker Desktop"And then try claude code, if that works.. then just reinstall your docker desktop.. hope it helps
If you are using docker then it is very likely an issue with docker and the network settings -> Simple Fix:
<img width="980" alt="Image" src="https://github.com/user-attachments/assets/17ef250f-a0e1-4958-ae95-2dfcd7bb6c64" />
This should work, at least it worked for me.
Same issue here - in terminal of vscode on macOS but NOT in iTerm2 outside of vscode !!!
How can this cloudflare Shield issue be dependent on the type of terminal ?
Can I maybe use a different vscode terminal version or any terminal setup/config maybe... weird!
I too am encountering this problem (specifically, getting a Cloudflare "Just a moment..." page. It seems dependent on which local network I'm connected to - it seems to happen much more often whether tethered to my mobile device.
for me this happens when connecting via iPhone Mobile Hotspot. Obviously they are not prepared for Mobile traffic. Can't believe this happening in 2025...
For MacOS, i discovered the following setting to be applied properly: https://github.com/anthropics/claude-code/issues/5825#issuecomment-3190959715
Hi everyone,
First, I want to apologize for the long silence on this issue. I understand how frustrating these connection errors have been, especially when they interrupt your workflow. You deserve better communication from us, and I'm sorry we haven't been more responsive.
This bug is a combination of quite a few issues, but most of them revolve around networking or proxy settings. There are some countries where you might see this issue because using Claude Code from those locations violates our AUP, but that's clearly not most of the issues in this thread. Here are some of the things we've done to address some of the root causes contributing to the issues in this thread:
For Connection/Network Issues:
The Core CloudFlare Issue:
The root cause is our CloudFlare security configuration treating CLI/terminal requests as potential threats. This requires careful coordination between our security and infrastructure teams to adjust settings without compromising overall security. While we marked this as high priority in April, the solution has proven more complex than anticipated due to:
Current Workarounds:
I acknowledge these workarounds are not acceptable as permanent solutions. We're actively working with our infrastructure team on a proper fix.
Thank you for your patience and detailed reports—they help us understand the scope and work toward solutions!
Well everything was working with no resets (on my home wifi) for a solid 6 days or so. And then today in the middle of a coding session
So back to the cellular hotspot, but it's annoying.
I think I messaged support about this and they never responded.
I'll these answers tell users to take extreme action to fix something that fundamentally has to be addressed by Anthropic, not by users. We properly installed the claude code cli and properly ran it. What else can Anthropic want?
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Wasted money 2x with this product. Thought it was Cursor that was having the issue, so moved my ultra plan directly to anthropic.
Constant API can't connect issues from API and Claude Code. No, message except "API Error: Connection error."
Still happening here, I'm pretty sure my ISP is blocking it. But getting them to even understand how DNS works is a struggle, so I just use a free VPN and it's no issue (but some sites will deliberately not work if you're on a VPN so it's a minor hassle).
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.
same issue here...
Thanks for the context on the macOS permission model, @dhollman – that balancing act between security and usability is definitely tricky to get right, but your explanation makes the constraints much clearer.
(Off-topic, but just wanted to say I'm a big fan of your 'Cute C++ Tricks' talks and mdspan work! It's awesome to see that high-performance/systems mindset being applied here at Anthropic.)
@dhollman To help debug the Cloudflare rules, here is a specific cf-ray ID from a blocked request on my machine (WSL2/Ubuntu):
Ray ID: 9ca45bb348ac3c13-BLR
User-Agent: claude-code/0.2.56
Time: 2026-02-07 22:15:02 +05:30
Hopefully, looking up this specific Ray ID in the WAF logs will pinpoint exactly which heuristic is flagging the CLI as a bot. Happy to run more targeted curl traces if you need to compare passing vs. failing fingerprints!
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.