claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Unable to connect to Anthropic services when running "claude" in terminal for claude code

Open mikelibg opened this issue 11 months ago • 47 comments

Image

Getting the above error when trying to run claude code in terminal from valid country.

Claude version: 0.2.29 (Claude Code) Node version: v23.6.0 npm version: 10.9.2

Tried running it also with bedrock setup but still getting the same error (btw, even with bedrock setup the error is still for api.anthropic.com)

CLAUDE_CODE_USE_BEDROCK=1
ANTHROPIC_MODEL='us.anthropic.claude-3-7-sonnet-20250219-v1:0'
AWS_ACCESS_KEY_ID=***PROPER_VALUE
AWS_SECRET_ACCESS_KEY=***PROPER_VALUE
AWS_SESSION_TOKEN=***PROPER_VALUE

Regardless there is no way to debug it further using cli (debug/verbose). I've run wireshark to get more information and I am getting the following handshake errors:

453 HTTP error on Client Hello (SNI=api.anthropic.com) using TLSv1.3 protocol. 457 HTTP error on Client Hello (SNI=console.anthropic.com) using TLSv1.3 protocol. 457 HTTP error on Client Hello (SNI=statsig.anthropic.com) using TLSv1.3 protocol.

mikelibg avatar Apr 02 '25 10:04 mikelibg

@mikelibg were you able to OAuth successfully to your Anthropic Console account?

sid374 avatar Apr 03 '25 18:04 sid374

Closing for inactivity. Feel free to re-open when you have a chance to respond.

bcherny avatar Apr 05 '25 21:04 bcherny

Hi @sid374 , sorry for the late reply, was not available during these days. Yes, I was able to connect to the Anthropic Console account with no issue. It seems to happen only with the cli.

@bcherny Can you please re-open the issue (it seems I dont have an option to do it), I am available from now on.

mikelibg avatar Apr 08 '25 08:04 mikelibg

I also have this problem, how can you get this work?

Hi @sid374 , sorry for the late reply, was not available during these days. Yes, I was able to connect to the Anthropic Console account with no issue. It seems to happen only with the cli.

@bcherny Can you please re-open the issue (it seems I dont have an option to do it), I am available from now on.

Xuyaoyan avatar Apr 09 '25 07:04 Xuyaoyan

@mikelibg @Xuyaoyan could you please check if you're able to make a request to the anthropic API from your machines?

curl -X POST https://api.anthropic.com/v1/messages \
  -H "x-api-key: my_api_key" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-3-7-sonnet-20250219",
    "max_tokens": 20000,
    "temperature": 1,
    "system": "answer briefly",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "hello claude!"
          }
        ]
      }
    ]
  }'

Use any non-claude code API key from your console accounts.

sid374 avatar Apr 09 '25 16:04 sid374

Got proper response, have enough credits, while still getting the describe error when running claude in terminal for claude code.

{
  "id": "msg_01Htot89TUejJk4SGz7gAe5g",
  "type": "message",
  "role": "assistant",
  "model": "claude-3-7-sonnet-20250219",
  "content": [
    {
      "type": "text",
      "text": "Hello! How can I assist you today?"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 12,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "output_tokens": 12
  }
}

Moreover, I enabled AWS bedrock setup with proper aws token and flags, but still when running the claude command, wireshark shows I am going directly to anthropic instead of aws.

P.S. I am able to properly work with AWS bedrock claude on the same laptop (macbook m1 pro) with lightllm and using direct requests as you mentioned.

mikelibg avatar Apr 09 '25 19:04 mikelibg

@sid374 can you please advise what else can be done to understand why the call to api.claude is rejected or why it is even going to this api, while I defined bedrock api to be used with claude code?

mikelibg avatar Apr 14 '25 10:04 mikelibg

I am having the same issue. I can authenticate via OAuth to claude.ai. When I connect directly to the API (using the curl command above), I get the successful response. When I run claude from the command line (after freshly installing v0.2.72) I get

│ ✻ Welcome to Claude Code research preview! │
╰────────────────────────────────────────────╯

 Unable to connect to Anthropic services

 Failed to connect to console.anthropic.com: Request failed with status code 403

 Please check your internet connection and network settings.

 Note: Claude Code might not be available in your country. Check supported countries at https://anthropic.com/supported-countries

I am in the United States, not using any kind of VPN or proxy.

Please advise what can be done to diagnose or provide additional information.

rdeetz avatar Apr 18 '25 00:04 rdeetz

I'm also getting this issue in the United Kingdom.

  • I can authenticate via OAuth to claude.ai
  • When I connect directly to the API (using the curl command above), I get the successful response.
  • When I run claude from the command line I get the 403 error ➕

sam-briggs-depop avatar Apr 18 '25 01:04 sam-briggs-depop

I am having the same issue. I can authenticate via OAuth to claude.ai. When I connect directly to the API (using the curl command above), I get the successful response. When I run claude from the command line (after freshly installing v0.2.72) I get

│ ✻ Welcome to Claude Code research preview! │
╰────────────────────────────────────────────╯

 Unable to connect to Anthropic services

 Failed to connect to console.anthropic.com: Request failed with status code 403

 Please check your internet connection and network settings.

 Note: Claude Code might not be available in your country. Check supported countries at https://anthropic.com/supported-countries

I am in the United States, not using any kind of VPN or proxy.

Please advise what can be done to diagnose or provide additional information.

lol I tried again this morning (changed nothing, just re-ran claude) and it worked 🤷🏻

rdeetz avatar Apr 18 '25 14:04 rdeetz

Resolved my problem by updating the openssl from 3.4.0 to 3.4.1 on my mac. So if you have my use case run the following in terminal:

brew update
# upgrading all formulas
brew upgrade
# or upgrading specifically openssl
brew install openssl

mikelibg avatar Apr 20 '25 13:04 mikelibg

Updating to openssl 3.4.1 didn't solve it for me. Still searching for ways to resolve it. My particular problem is Failed to connect to console.anthropic.com: Request failed with status code 403.

@mikelibg how did you arrive at your solution? Did you find any logs?

ndiezel0 avatar Apr 22 '25 22:04 ndiezel0

I am using openssl 3.4.1 and having the same issue.

ZhengRui avatar May 01 '25 05:05 ZhengRui

For whom may be insterested : Same issue. I am on windows but with docker installed. After uninstall Docker, it works fine !

sergeanton avatar May 02 '25 09:05 sergeanton

I typically run a few instances of Claude Code concurrently, after restarting one of my instances I noticed this issue for the first time (01MAY2025). Oddly enough, my remaining instances were still coding away. Once all instances were restarted, the error became a total block.

I access Claude Code via wsl Ubuntu in the states.

I tried all of these things, which did not work:

  • Resetting DNS configuration
  • Enabling/disabling VPN
  • Removing auth.json
  • Restarting wsl
  • uninstalling/reinstalling Claude Code
  • uninstalling/reinstalling Ubuntu

sergeanton's recommendation led me to update Docker Desktop, after updating, everything is working fine.

I noticed that anthropic opened up authentication via Max, and Docker updated recently. Curious if these are related to my interdiction.

ebeckner-looptech avatar May 02 '25 12:05 ebeckner-looptech

I have the same issue. I am running claude desktop with a max plan. I am on windows but accessing claude through wsl in the terminal. This is the error message that I'm getting: ╭────────────────────────────────────────────╮ ✻ Welcome to Claude Code research preview! │ ╰────────────────────────────────────────────╯

Unable to connect to Anthropic services

Failed to connect to api.anthropic.com:

Please check your internet connection and network settings.

Note: Claude Code might not be available in your country. Check supported countries at https://anthropic.com/supported-countries

How do I fix this, want to try claude code asap.

vrishbhanusingh avatar May 05 '25 08:05 vrishbhanusingh

Hi everyone!

I was having the same issue (WSL on Windows), and I was able to fix it by running sudo apt-get update, sudo apt-get upgrade -y, and then restarting.

Hope this helps!

SEDIDEL avatar May 05 '25 16:05 SEDIDEL

I am experiencing this issue, as well. Out of the blue. No amount of upgrading on my windows or Linux boxens are solving it. Local install, no docker. Issue persists. I cleared configurations, but it remains the same.

notnullxyz avatar May 07 '25 09:05 notnullxyz

Same here, I use it in several terminals with two accounts, and after /login it suddenly started to happen. None of the above solutions seem to work in my case.

jvirico avatar May 07 '25 09:05 jvirico

Same for me, it suddenly said unable to connect to Anthropic services.

╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview!        │
╰───────────────────────────────────────────────────╯

 Unable to connect to Anthropic services

 Failed to connect to console.anthropic.com: Request failed with status code 403

 Please check your internet connection and network settings.

 Note: Claude Code might not be available in your country. Check supported countries at
 https://anthropic.com/supported-countries

Folyd avatar May 07 '25 10:05 Folyd

I guess Anthropic blocked all cloud virtual machine IPs? I tested it not working any more for Microsoft Azure.

$ curl https://ipinfo.io
{
  "ip": "1*.8*.56.23*",
  "city": "San Jose",
  "region": "California",
  "country": "US",
  "loc": "37.3394,-121.8950",
  "org": "AS8075 Microsoft Corporation",
  "postal": "95025",
  "timezone": "America/Los_Angeles",
  "readme": "https://ipinfo.io/missingauth"

$ curl https://ipinfo.io
{
  "ip": "2*.17*.127.6*",
  "city": "Phoenix",
  "region": "Arizona",
  "country": "US",
  "loc": "33.4484,-112.0740",
  "org": "AS8075 Microsoft Corporation",
  "postal": "85001",
  "timezone": "America/Phoenix",
  "readme": "https://ipinfo.io/missingauth"

Folyd avatar May 07 '25 10:05 Folyd

Carpet bombing entire nets apparently. https://github.com/anthropics/claude-code/issues/984 @Folyd - You're on Azure, and we see the same on DO.

notnullxyz avatar May 07 '25 10:05 notnullxyz

Not working either from my Azure VM in West Europe region.

jvirico avatar May 07 '25 10:05 jvirico

I'm on Digital Ocean - exactly the same issue, started about six hours ago. Very frustrating.

printcotton avatar May 07 '25 19:05 printcotton

Solved for me in Azure VMs.

jvirico avatar May 08 '25 07:05 jvirico

And now for me in DO.

printcotton avatar May 08 '25 08:05 printcotton

Solved in DO.

notnullxyz avatar May 08 '25 09:05 notnullxyz

I was using WLS2 on CentOS until yesterday, and it was working then, but when I tried to get the latest version to use the MAX account, it stopped working.

$ curl -I https://console.anthropic.com/healthz --max-time 10 HTTP/2 403 date: Sun, 11 May 2025 11:14:24 GMT content-type: text/html; charset=UTF-8 content-length: 6980 accept-ch: Sec-CH-UA-Bitness, Sec-CH-UA-Arch, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Platform, Sec-CH-UA, UA-Bitness, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform-Version, UA-Platform, UA cf-mitigated: challenge critical-ch: Sec-CH-UA-Bitness, Sec-CH-UA-Arch, Sec-CH-UA-Full-Version, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Platform, Sec-CH-UA, UA-Bitness, UA-Arch, UA-Full-Version, UA-Mobile, UA-Model, UA-Platform-Version, UA-Platform, UA cross-origin-embedder-policy: require-corp cross-origin-opener-policy: same-origin cross-origin-resource-policy: same-origin origin-agent-cluster: ?1 permissions-policy: accelerometer=(),autoplay=(),browsing-topics=(),camera=(),clipboard-read=(),clipboard-write=(),geolocation=(),gyroscope=(),hid=(),interest-cohort=(),magnetometer=(),microphone=(),payment=(),publickey-credentials-get=(),screen-wake-lock=(),serial=(),sync-xhr=(),usb=() referrer-policy: same-origin server-timing: chlray;desc="93e140a66df280c3" x-content-type-options: nosniff x-frame-options: SAMEORIGIN cache-control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0 expires: Thu, 01 Jan 1970 00:00:01 GMT set-cookie: __cf_bm=PYtN_RENAxL4xx0_HEZ3Jmihdt7K.a7mjL47i75gD8M-1746962064-1.0.1.1-PJs9PMut0cmMEOpJUK7Px3P1tF5xZN4O8.PIygw9zFLenj68NH7pVRbgG_eP5QombRBVOvtW1JB35Y2vKRk48RO_RA55Fmh57OPzlTxI5Lw; path=/; expires=Sun, 11-May-25 11:44:24 GMT; domain=.console.anthropic.com; HttpOnly; Secure; SameSite=None server: cloudflare cf-ray: 93e140a66df280c3-NRT alt-svc: h3=":443"; ma=86400

Yuutakasan avatar May 11 '25 05:05 Yuutakasan

In WSL, the solution for me was to set the networking mode to mirrored.

In Powershell:

wsl --shutdown
notepad "$env:USERPROFILE\.wslconfig"

And in this file:

[wsl2]
networkingMode=mirrored

The issue was that WSL was essentially acting like a network proxy.

kheasley avatar May 15 '25 02:05 kheasley

I was able to resolve the issue by following the steps below to set up Cloudflare WARP on Linux:

Install and enable Cloudflare WARP client

curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg &&
echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list &&
sudo apt update &&
sudo apt install -y cloudflare-warp &&
sudo warp-cli register &&
sudo warp-cli connect

These commands will: 1. Import the Cloudflare GPG key 2. Add the Cloudflare APT repository 3. Update the package list 4. Install the Cloudflare WARP client 5. Register the client 6. Connect to the WARP network

Let me know if you’re using a different Linux distribution so I can adjust the steps accordingly.

Yuutakasan avatar May 15 '25 05:05 Yuutakasan