Sandbox proxy fails with 502 Bad Gateway under sustained request load
Resolved 💬 3 comments Opened Jan 16, 2026 by tobihagemann Closed Feb 27, 2026
Description
The sandbox proxy (running on localhost:52010) becomes unstable when handling multiple consecutive HTTP requests to allowed hosts, causing "Tunnel connection failed: 502 Bad Gateway" errors.
Reproduction Steps
- Add a host to the sandbox network allowlist (e.g., via
/sandbox) - Run a Python script that makes multiple consecutive API requests to that host using
urllib.request - After approximately 5-10 rapid requests, subsequent requests fail with "502 Bad Gateway"
- After ~2 seconds of inactivity, requests start working again
Observed Behavior
- First few requests succeed
- Proxy enters a "bad state" after sustained load
- All subsequent requests fail with:
{"error": "Cannot connect: Tunnel connection failed: 502 Bad Gateway"} - Proxy recovers after a brief pause (~2 seconds)
Expected Behavior
The sandbox proxy should handle consecutive requests to allowed hosts without failing.
Environment
- Claude Code version: 2.1.9
- Platform: macOS (Darwin 25.2.0)
- Python scripts using
urllib.request(which respectsHTTP_PROXY/HTTPS_PROXYenvironment variables set by the sandbox)
Workaround
Using dangerouslyDisableSandbox: true bypasses the proxy entirely and works reliably.
Additional Context
The proxy environment variables are set by Claude Code itself:
HTTP_PROXY=http://localhost:52010
HTTPS_PROXY=http://localhost:52010
The issue appears to be related to connection handling or rate limiting in the proxy, not the destination host (which is correctly allowlisted).
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗