[BUG] Backgrounded/reconnected sessions do not use the configured proxy and fail to connect (ConnectionRefused)
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?
In an environment where a web proxy is configured via http_proxy/https_proxy environment variables at the user/system level.
After a session is backgrounded or reconnected to, all requests stop working with a ConnectionRefused error:
API Error: Unable to connect to API (ConnectionRefused)
Looks like once a session has been backgrounded, it starts running under a different process context. Examining this process in Process Explorer shows that while it inherits most of the user's environment variables, http_proxy and https_proxy are missing. From this point forward, it is impossible to do anything meaningful in this session since all requests fail with connection errors.
Meanwhile, new sessions from new invocations of claude connect without issue, at least until they are backgrounded or reconnected to at which point they fail similarly.
What Should Happen?
Claude should connect via the inherited http_proxy or https_proxy proxy when in background sessions.
Error Messages/Logs
API Error: Unable to connect to API (ConnectionRefused)
Steps to Reproduce
- Be on a Windows system that blocks internet access except through a HTTP proxy
- Configure http_proxy and https_proxy environment variable at the user/system level (not in Claude settings)
- Launch claude cli
- Send a test message
/background- Re-open the session via
claude agentsorclaude attach - Send a test message
- API connection errors occur
Claude Model
Other
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.212
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗