[BUG] OAuth login fails with ERR_INVALID_IP_ADDRESS behind corporate proxy (regression since 2.0.37)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Environment
- Claude Code Version: 2.0.53
- Operating System: RHEL-based container (Dataiku Code Studio)
- Terminal: bash
- Platform: Anthropic API
- Node.js: 18.x
- Network: Corporate proxy (HTTP/HTTPS)
Bug Description
OAuth login fails with ERR_INVALID_IP_ADDRESS when running Claude Code behind a corporate proxy. The error occurs immediately when running claude or /login.
Error message:
Unable to connect to Anthropic services
Failed to connect to api.anthropic.com: ERR_INVALID_IP_ADDRESS
Key Finding: API Works, OAuth Doesn't
The network path to Anthropic is fully functional:
$ curl -v https://api.anthropic.com 2>&1 | head -20
* Uses proxy env variable https_proxy == 'http://b2b-http.dhl.com:8080'
* Connected to b2b-http.dhl.com (10.28.254.17) port 8080
* Proxy replied 200 to CONNECT request
# ... TLS handshake succeeds
API key authentication works:
$ export ANTHROPIC_API_KEY="sk-ant-..."
$ claude --print "hello"
Credit balance is too low # ← Connection succeeded, just no credits
Only OAuth login fails with the IP address error.
Attempted Workarounds (None Worked)
| Attempt | Result |
|---------|--------|
| export NODE_OPTIONS="--dns-result-order=ipv4first" | No effect |
| export CLAUDE_CODE_OAUTH_TOKEN=<token from setup-token> | Still prompts for login |
| export ANTHROPIC_AUTH_TOKEN=<token> | No effect |
| Disable IPv6 via sysctl | Permission denied in container |
Working Workaround
Downgrading to v2.0.37 fixes the issue. A colleague using 2.0.37 behind the same proxy can login successfully.
npm install -g @anthropic-ai/claude-code@2.0.37
claude /login # Works
Regression
- 2.0.37: ✅ Works behind corporate proxy
- 2.0.53: ❌ Fails with ERR_INVALID_IP_ADDRESS
Exact version where regression occurred is unknown (not tested: 2.0.38–2.0.52).
Expected Behavior
OAuth login should work behind corporate proxies when:
HTTPS_PROXYis correctly setcurlcan reachapi.anthropic.comthrough the proxy- API key authentication works
Related Issues
- #12081 -
/login leads to invalid IP Address - #12040 -
OAuth authentication is currently not supported - #11464 -
OAuth authentication fails in proxy environment - #332 -
Claude Code unable to connect through corporate proxy in WSL
Additional Context
This appears to be a regression in how the OAuth flow handles DNS resolution or proxy tunneling. The underlying API connectivity is fine — only the OAuth code path is affected.
What Should Happen?
Claude Code VSCode extension should authenticate the session successfully.
Error Messages/Logs
Steps to Reproduce
Steps to Reproduce
- Run Claude Code in a containerized environment behind a corporate HTTP proxy
- Set
HTTPS_PROXY=http://your-proxy:port - Run
claudeorclaude /login - Observe
ERR_INVALID_IP_ADDRESSerror
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.0.37
Claude Code Version
2.0.53
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
12 Comments
OAuth Proxy Regression - Root Cause Identified
Excellent bug report. The regression between 2.0.37 and 2.0.53 is likely in how OAuth handles DNS resolution through proxies.
Immediate Workaround
Since 2.0.37 works, pin that version:
Root Cause Analysis
The error
ERR_INVALID_IP_ADDRESSduring OAuth (but not API calls) suggests the OAuth flow is:Why API works but OAuth doesn't:
$HTTPS_PROXY)Diagnostic for Anthropic Team
Compare DNS resolution paths:
Potential Fix Locations (For Anthropic Team)
Option 1: Force IPv4 for OAuth
Option 2: Explicit proxy for OAuth callback
Option 3: DNS resolution order
Temporary Workarounds for Users
Workaround 1: API Key Instead (no OAuth needed)
Workaround 2: SSH Tunnel (if you have external access)
Workaround 3: Direct IP (risky, may break)
What Would Help Debug
If you can share:
``
bash
``getent hosts api.anthropic.com
``
bash
``# While /login is waiting:
netstat -tlnp | grep claude
``
bash
``node --version
Node 18.x changed IPv6 behavior - if 2.0.38+ started using Node 18 features, that's the regression.
Expected Fix
Anthropic should:
$HTTPS_PROXYin OAuth flow--no-ipv6flag for OAuthThis is a HIGH priority fix since it blocks enterprise users.
Diagnostic Data
DNS Resolution (returns IPv6 first):
Node Version:
Engine Requirements (identical):
Root Cause
DNS resolves
api.anthropic.comto IPv6 (2607:6bc0::10) first. Corporate proxy doesn't support IPv6 tunneling. OAuth code in 2.0.53 appears to resolve DNS directly and attempt IPv6 connection, bypassing proxy. Version 2.0.37 does not exhibit this behavior.NODE_OPTIONS="--dns-result-order=ipv4first"has no effect, suggesting OAuth uses a library with its own DNS resolution.Wrong: the latest working version is: v2.0.47
Having the same issue
The problem was resolved but come back with version 2.0.65
Have the same issue. Found a workaround by disabling proxy to pass the oauth login and enabling it after it
Here's my new finding with the problem.
the proxy is not set in my environment variables but in ~/.claude/settings.json. It's working correctly with the version 2.0.64 but not with the newest.
If I set proxy in environment variables before launching claude the recent version are working.
So I suspect that the oauth system which renew the token is not using the ~/.claude/settings.json in the newest version.
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.
I must admit that seeing this being autoclosed is a bit frustrating. I wonder if there is any way to bring this up to Anthropic's attention, at least to get a statement from them.
shame, i have the issue now haha
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
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.