Skip to content

fix(miniflare): bypass proxy for local inspector connections#11568

Closed
Zuckjet wants to merge 2 commits intocloudflare:mainfrom
Zuckjet:fix/miniflare-proxy
Closed

fix(miniflare): bypass proxy for local inspector connections#11568
Zuckjet wants to merge 2 commits intocloudflare:mainfrom
Zuckjet:fix/miniflare-proxy

Conversation

@Zuckjet
Copy link

@Zuckjet Zuckjet commented Dec 9, 2025

Fixes #8906

When users have proxy environment variables set (HTTP_PROXY, HTTPS_PROXY, etc.),
the local development server fails to start with a "TypeError: fetch failed" error.

Root cause

  • Wrangler detects proxy environment variables and sets a global ProxyAgent
  • Miniflare's InspectorProxyController makes a fetch request to 127.0.0.1
    to connect to the workerd inspector
  • This local request incorrectly goes through the proxy, which typically
    cannot handle localhost addresses, causing the connection to fail

Solution

Modified InspectorProxyController.updateConnection() to use a dedicated
Agent for the local fetch request, bypassing the global proxy settings.
Local inspector connections should never be proxied.


  • Tests
    • Tests included/updated
    • Tests not necessary because: Tested locally with proxy environment variables set
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: This should be defalut behavior
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: Not a patch change, not a Wrangler change

@Zuckjet Zuckjet requested a review from a team as a code owner December 9, 2025 06:19
@changeset-bot
Copy link

changeset-bot bot commented Dec 9, 2025

🦋 Changeset detected

Latest commit: cd09cfe

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@edmundhung
Copy link
Member

Hi @Zuckjet, thanks for the contribution. I have a look of the issue and believe this is a side effect from wrangler proxy agent and so it's better handled in the wrangler side.

I have pushed a fix in #12516 and should be landed soon.

@edmundhung edmundhung closed this Feb 11, 2026
@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Cannot start Vite dev server with proxy environment variables

3 participants