[BUG] - Unable to connect to Anthropic services - behind corporate proxy
Resolved 💬 19 comments Opened May 28, 2025 by neilmispelaar Closed May 29, 2025
💡 Likely answer: A maintainer (sid374, contributor)
responded on this thread — see the highlighted reply below.
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 1.0.3 (Claude Code)
- Operating System: Linux Mint 22.1
- Terminal: Default terminal app
Bug Description
Error message: Unable to connect to Anthropic services and Request failed with status code 400
Our organization leverages a corporate proxy. We access that proxy on Linux using CNTML.
I can use the web version of Claude without any issues, and the linux machine can browse the internet, npm works, there aren't any indications of network errors on the machine.
Unfortunately, when running claude in the terminal I get the Unable to connect to Anthropic services error message.
The HTTPS_PROXY environment variable is set correctly to http://localhost:3128 which is the CNTLM default.
Could there be any other environment variables or other settings that I need to update to make this work?
Steps to Reproduce
- Run
Claude - View the
Unable to connect to Anthropic serviceserror message.
Expected Behavior
- Run
Claude - No error message
Actual Behavior
- Run
Claude - View the
Unable to connect to Anthropic serviceserror message.
Additional Context
Happy to share whatever would be helpful.
19 Comments
If you upgrade to 1.0.4 -
/statusshould show you if your proxy is being picked up correctly. Could you please run that and report what you see?@neilmispelaar are you able to proceed past that error message, or are you stuck on that "Unable to connect to Anthropic services" error?
The error "Unable to connect to Anthropic services" indicates failure to connect to a couple endpoints required for auth. You may get more information from
ANTHROPIC_LOG=debug claude --verbose --debug.I'll check on if there are any known issues here, since your configuration (setting
HTTPS_PROXY) looks good.I am seeing the same issue behind proxy. Claude is in the WSL on Windows.
Proxy are configured in the ~/.bashrc.
wget, curl, apt are working fine.
Here is the output from Claude status:
⎿ API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth token has expired. Please obtain a new
token or refresh your existing token."}}
Claude Code Status v1.0.4
Working Directory
L /mnt/c/Users/user/projects/project1
Account • /login
L Login Method: Claude Max Account
L Email: user@yahoo.com
API Configuration
L Proxy: http://proxy.some-company.com:3128
Model • /model
L Default Uses Opus or Sonnet based on Max usage limits (currently Opus)
@anvanster, is that 401 error part of the
claude /statusoutput? Are you running into the same "Unable to connect to Anthropic services" issue?@ant-kurt yes, 401 appears after as a result of running /status in the Claude prompt.
Initialization is ok:
jason@soc-TTR342E3:/mnt/c/Users/user/projects/project1$ claude
╭────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
│ cwd: /mnt/c/Users/user/projects/private/resume-service │
╰────────────────────────────────────-───╯
╭─────────────────────────────────────────────────────╮
│ > Try "write a test for <filepath>"
╰─────────────────────────────────────────────────────╯
? for shortcuts
After I run /status in the prompt I see the 401.
Hm, and while I was writing the comment, version got upgraded to 1.0.5.
There is no 401 message anymore after running /status. Now it appears after an actual prompt:
⎿ (no content)
⎿ API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth token has expired. Please obtain a new
token or refresh your existing token."}}
Here is output with DEBUG=*
follow-redirects options {maxRedirects: 21,
maxBodyLength: Infinity,
protocol: 'http:',
path: 'https://console.anthropic.com/v1/oauth/token',
method: 'POST',
headers: [Object: null prototype] {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
'User-Agent': 'axios/1.8.4',
'Content-Length': '208',
'Accept-Encoding': 'gzip, compress, deflate, br',
host: 'console.anthropic.com'
},
agents: { http: undefined, https: undefined },
auth: undefined,
family: undefined,
beforeRedirect: [Function: uZ9],
beforeRedirects: { proxy: [Function: G] },
hostname: 'proxy.some-company.com',
port: '3128',
host: 'proxy.some-company.com',
agent: undefined,
nativeProtocols: {
'http:': {
_connectionListener: [Function: connectionListener],
METHODS: [Array],
STATUS_CODES: [Object],
Agent: [Function],
ClientRequest: [Function: ClientRequest],
IncomingMessage: [Function: IncomingMessage],
OutgoingMessage: [Function: OutgoingMessage],
Server: [Function: Server],
ServerResponse: [Function: ServerResponse],
createServer: [Function: createServer],
validateHeaderName: [Function],
validateHeaderValue: [Function],
get: [Function: C],
request: [Function: C],
setMaxIdleHTTPParsers: [Function: setMaxIdleHTTPParsers],
maxHeaderSize: [Getter],
globalAgent: [Getter/Setter]
},
'https:': {
Agent: [Function: Agent],
globalAgent: [Agent],
Server: [Function: Server],
createServer: [Function: createServer],
get: [Function: C],
request: [Function: C]
}
}
}
@anvanster can you try running
/loginagain?@ant-kurt Better now. I am getting a URL to get OAuth token through "max" (url modified).
403 when I am pasting it to the terminal.
Retried multiple times.
██████╗██╗ █████╗ ██╗ ██╗██████╗ ███████╗
██╔════╝██║ ██╔══██╗██║ ██║██╔══██╗██╔════╝
██║ ██║ ███████║██║ ██║██║ ██║█████╗
██║ ██║ ██╔══██║██║ ██║██║ ██║██╔══╝
╚██████╗███████╗██║ ██║╚██████╔╝██████╔╝███████╗
╚═════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
██████╗ ██████╗ ██████╗ ███████╗
██╔════╝██╔═══██╗██╔══██╗██╔════╝
██║ ██║ ██║██║ ██║█████╗
██║ ██║ ██║██║ ██║██╔══╝
╚██████╗╚██████╔╝██████╔╝███████╗
╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝
Browser didn't open? Use the url below to sign in:
https://claude.ai/oauth/authorize?code=true&client_id=9d.........a-1234-5678-1234-59..........2f5e&response_type=code&redirect_uri=https%3A%2F%2Fconsole.anthropic.com%2Foauth%2Fcode%2Fcallback&scope=org%3Acreate_api_key+user%3Aprofile+user%3Ainference&code_challenge=KDW2_PU239_EDm...........89UI&code_challenge_method=S256&state=txNzYMRYOlBI4pbcyNJwQe16gD-DkG.........roQ
OAuth error: Request failed with status code 403
Press Enter to retry.
Appreciate your continued help with this.
Here is what I'm currently seeing:
<img width="572" alt="Image" src="https://github.com/user-attachments/assets/ffd34322-2b9f-4864-b53b-81485cb8cbb8" />
Debug Output
And here is the debug output
<details><summary>Output:</summary>
</details>
WGET Output
Just for my own sanity, I checked
wgetagainst the endpoints in the debug statements:I have a similar issue - cannot get past the connectivity check. This is with
HTTPS_PROXYenv set@prndP
Hi there,
How do you get this JSON output?
Would love to get the output of my machine and compare.
On our side, we use linux and are running CNTLM to access the corporate proxy and it's configured to use HTTP even for HTTPS since the proxy is running locally on the machine.
@neilmispelaar you can start your Claude with
It will produce JSON debug messages
Can you see how this feels once
v1.0.7is released?@ant-kurt - Absolutely!
Sounds good - just waiting for the
v1.0.7drop. ThanksIs there an ETA for 1.0.7 release?
v1.0.7 landed a few days ago - let me know if you're still having issues with proxy connectivity.
@ant-kurt Thank you. Looks good in 1.0.8 version. NO issues with connection over proxy.
Hi @ant-kurt
Can confirm that
1.0.9is working perfectly behind our CNTLM / Corporate Proxy.This is super wonderful.
Thanks for all of your help with this.
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.