[BUG] - Unable to connect to Anthropic services - behind corporate proxy
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- 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.
If you upgrade to 1.0.4 - /status should 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:
try ⎿ 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: [email protected]
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 /status output? 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
╰─────────────────────────────────────────────────────╯
? 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:
/status ⎿ (no content)
what is the api 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."}}
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 /login again?
@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:
Debug Output
And here is the debug output
DEBUG=* claude
Output:
──────────────────────────╮
│ ✻ Welcome to Claude Code │
╰──────────────────────────╯
follow-redirects options {
maxRedirects: 21,
maxBodyLength: Infinity,
protocol: 'http:',
path: 'https://api.anthropic.com/api/hello',
method: 'GET',
headers: [Object: null prototype] {
Accept: 'application/json, text/plain, */*',
'User-Agent': 'claude-cli/1.0.4 (external, cli)',
'Accept-Encoding': 'gzip, compress, deflate, br',
host: 'api.anthropic.com'
},
agents: { http: undefined, https: undefined },
auth: undefined,
family: undefined,
beforeRedirect: [Function: pD9],
beforeRedirects: { proxy: [Function: G] },
hostname: 'localhost',
port: '3128',
host: 'localhost',
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: get],
request: [Function: request],
setMaxIdleHTTPParsers: [Function: setMaxIdleHTTPParsers],
maxHeaderSize: [Getter],
globalAgent: [Getter/Setter],
WebSocket: [Getter],
CloseEvent: [Getter],
MessageEvent: [Getter]
},
'https:': {
Agent: [Function: Agent],
globalAgent: [Agent],
Server: [Function: Server],
createServer: [Function: createServer],
get: [Function: get],
request: [Function: request]
}
}
} +0ms
follow-redirects options {
maxRedirects: 21,
maxBodyLength: Infinity,
protocol: 'http:',
path: 'https://console.anthropic.com/v1/oauth/hello',
method: 'GET',
headers: [Object: null prototype] {
Accept: 'application/json, text/plain, */*',
'User-Agent': 'claude-cli/1.0.4 (external, cli)',
'Accept-Encoding': 'gzip, compress, deflate, br',
host: 'console.anthropic.com'
},
agents: { http: undefined, https: undefined },
auth: undefined,
family: undefined,
beforeRedirect: [Function: pD9],
beforeRedirects: { proxy: [Function: G] },
hostname: 'localhost',
port: '3128',
host: 'localhost',
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: get],
request: [Function: request],
setMaxIdleHTTPParsers: [Function: setMaxIdleHTTPParsers],
maxHeaderSize: [Getter],
globalAgent: [Getter/Setter],
WebSocket: [Getter],
CloseEvent: [Getter],
MessageEvent: [Getter]
},
'https:': {
Agent: [Function: Agent],
globalAgent: [Agent],
Server: [Function: Server],
createServer: [Function: createServer],
get: [Function: get],
╭──────────────────────────╮
│ ✻ Welcome to Claude Code │
╰──────────────────────────╯
Unable to connect to Anthropic services
Failed to connect to api.anthropic.com: Request failed with status code 400
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
WGET Output
Just for my own sanity, I checked wget against the endpoints in the debug statements:
wget https://api.anthropic.com/api/hello
--2025-05-29 00:29:13-- https://api.anthropic.com/api/hello
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 19 [application/json]
Saving to: ‘hello’
hello 100%[===================>] 19 --.-KB/s in 0s
2025-05-29 00:29:13 (862 KB/s) - ‘hello’ saved [19/19]
wget https://console.anthropic.com/v1/oauth/hello
--2025-05-29 00:31:24-- https://console.anthropic.com/v1/oauth/hello
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 19 [application/json]
Saving to: ‘hello.1’
hello.1 100%[===================>] 19 --.-KB/s in 0s
2025-05-29 00:31:24 (763 KB/s) - ‘hello.1’ saved [19/19]
I have a similar issue - cannot get past the connectivity check. This is with HTTPS_PROXY env set
{
status: 400,
statusText: 'Bad Request',
headers: {
date: 'Thu, 29 May 2025 15:07:08 GMT',
'content-type': 'application/json',
'content-length': '241',
connection: 'keep-alive',
vary: 'Accept-Encoding',
'x-robots-tag': 'none',
server: 'cloudflare',
},
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [ 'xhr', 'http', 'fetch' ],
transformRequest: [ [Function: A] ],
transformResponse: [ [Function: A] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: { FormData: [Function [FormData]], Blob: [class Blob] },
validateStatus: [Function: A],
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': undefined,
'User-Agent': 'cli-tool/1.0.5 (external, cli)',
'Accept-Encoding': 'gzip, compress, deflate, br'
},
method: 'get',
url: 'https://api.anthropic.com/api/hello',
allowAbsoluteUrls: true,
data: undefined
},
request: {
host: 'application-proxy.generic-corporate-proxy.com',
protocol: 'http:',
_socket: {
_host: 'application-proxy.generic-corporate-proxy.com'
}
},
data: `{
"error": {
"type": "invalid_request_error",
"message": "This request was sent over HTTP. Only HTTPS is supported for API use. Consider revoking your API key, as it was sent in plaintext over the internet with this request."
}
}`
}
@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
DEBUG*= claude
It will produce JSON debug messages
Can you see how this feels once v1.0.7 is released?
@ant-kurt - Absolutely!
Sounds good - just waiting for the v1.0.7 drop. Thanks
Is 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.9 is 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.