[BUG] Claude Code MCP does not use the NO_PROXY setting in environment variables
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?
My computer must use a proxy to connect to the Internet, so I set the HTTP_PROXY environment variable in settings.json, including NO_PROXY. By default, I can use Claude Code normally.
settings.json
{
"env": {
"HTTP_PROXY": "http://7.227.24.108:3128",
"HTTPS_PROXY": "http://7.227.24.108:3128",
"NO_PROXY": "localhost,127.0.0.1"
}
}
When I need to use MCP to connect to a localhost MCP Server, Claude Code does not correctly load NO_PROXY and still accesses the MCP Server through HTTP_PROXY, causing the request to fail.
.claude.json
{
"mcpServers": {
"vibe-annotations": {
"type": "http",
"url": "http://127.0.0.1:3846/mcp"
}
}
}
<img width="556" height="258" alt="Image" src="https://github.com/user-attachments/assets/b11f71e1-c2fd-4fe6-b4f4-0e7b00bdd4f5" />
What Should Happen?
When Claude Code connects to an HTTP MCP Server, it follows the NO_PROXY setting, allowing it to bypass the HTTP Proxy and access the MCP Server directly.
Error Messages/Logs
**Claude Debug Log**
2026-03-15T07:08:53.280Z [DEBUG] MCP server "vibe-annotations": No token data found
2026-03-15T07:08:55.717Z [DEBUG] MCP server "vibe-annotations": Initializing HTTP transport to http://127.0.0.1:3846/mcp
2026-03-15T07:08:55.718Z [DEBUG] MCP server "vibe-annotations": Node version: v24.3.0, Platform: win32
2026-03-15T07:08:55.718Z [DEBUG] MCP server "vibe-annotations": Environment: {"NODE_OPTIONS":"not set","UV_THREADPOOL_SIZE":"default","HTTP_PROXY":"http://7.227.24.108:3128","HTTPS_PROXY":"http://7.227.24.108:3128","NO_PROXY":"localhost,127.0.0.1"}
2026-03-15T07:08:55.719Z [DEBUG] MCP server "vibe-annotations": Proxy options: default
2026-03-15T07:08:55.719Z [DEBUG] MCP server "vibe-annotations": HTTP transport options: {"url":"http://127.0.0.1:3846/mcp","headers":{"User-Agent":"claude-code/2.1.63 (cli)"},"hasAuthProvider":true,"timeoutMs":60000}
2026-03-15T07:08:55.719Z [DEBUG] MCP server "vibe-annotations": HTTP transport created successfully
2026-03-15T07:08:55.720Z [DEBUG] MCP server "vibe-annotations": Client created, setting up request handler
2026-03-15T07:08:55.720Z [DEBUG] MCP server "vibe-annotations": Starting connection with timeout of 30000ms
2026-03-15T07:08:55.721Z [DEBUG] MCP server "vibe-annotations": Testing basic HTTP connectivity to http://127.0.0.1:3846/mcp
2026-03-15T07:08:55.721Z [DEBUG] MCP server "vibe-annotations": Parsed URL: host=127.0.0.1, port=3846, protocol=http:
2026-03-15T07:08:55.721Z [DEBUG] MCP server "vibe-annotations": Using loopback address: 127.0.0.1
2026-03-15T07:08:55.722Z [DEBUG] MCP server "vibe-annotations": No token data found
2026-03-15T07:08:55.726Z [DEBUG] MCP server "vibe-annotations": HTTP Connection failed after 9ms: Streamable HTTP error: Error POSTing to endpoint: <html><body><h1>502 Connection refused</h1><p><a href='http://cntlm.sf.net/'>Cntlm</a> proxy failed to complete the request.</p></body></html> (code: 502, errno: none)
2026-03-15T07:08:55.726Z [ERROR] MCP server "vibe-annotations" Error: Streamable HTTP error: Error POSTing to endpoint: <html><body><h1>502 Connection refused</h1><p><a href='http://cntlm.sf.net/'>Cntlm</a> proxy failed to complete the request.</p></body></html>
2026-03-15T07:08:55.727Z [DEBUG] MCP server "vibe-annotations": Connection failed after 10ms: Streamable HTTP error: Error POSTing to endpoint: <html><body><h1>502 Connection refused</h1><p><a href='http://cntlm.sf.net/'>Cntlm</a> proxy failed to complete the request.</p></body></html>
2026-03-15T07:08:55.727Z [ERROR] MCP server "vibe-annotations" Connection failed: Streamable HTTP error: Error POSTing to endpoint: <html><body><h1>502 Connection refused</h1><p><a href='http://cntlm.sf.net/'>Cntlm</a> proxy failed to complete the request.</p></body></html>
Steps to Reproduce
- Configure an HTTP Proxy for Claude Code
- Configure the MCP Server that needs to be connected
- Configure NO_PROXY to try bypassing the MCP Server
- Start Claude Code and try loading the MCP Server
- Check whether the MCP connection is successful and whether the NO_PROXY configuration takes effect
Claude Model
None
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
v2.1.63
Platform
Other
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗