cli icon indicating copy to clipboard operation
cli copied to clipboard

502 Bad Gateway Error When Using HTTP Proxy with `shopify theme dev`

Open reeswell opened this issue 7 months ago • 15 comments

Please confirm that you have:

  • [x] Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
  • [x] Reproduced the issue in the latest CLI version.

In which of these areas are you experiencing a problem?

Theme

Expected behavior

The CLI should successfully render the storefront through the configured HTTP proxy.

Actual behavior

The CLI fails to render the storefront with a 502 Bad Gateway error, despite proper proxy configuration.

Verbose output

Verbose output
Failed to render storefront with status 502 (Bad Gateway).
URL: [REDACTED]

TypeError: fetch failed
  at node:internal/deps/undici/undici:13510:13
  at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
  at async render2 [...]
  at async Object.handler [...]
  at async Server.<anonymous> [...]

Reproduction steps

1.Set HTTP proxy environment variables:

$env:SHOPIFY_HTTP_PROXY = "http://127.0.0.1:PORT"
$env:SHOPIFY_HTTPS_PROXY = "http://127.0.0.1:PORT"
2.Run shopify theme dev -e development
3.CLI starts successfully and provides preview URLs
4.Immediately encounters 502 Bad Gateway error

### Operating System

Windows 11

### Shopify CLI version (`shopify --version`)

@shopify/cli/0.0.0-snapshot-20250313171017

### Shell

powershell

### Node version (run `node -v` if you're not sure)

v22.15.1

### What language and version are you using in your application?

_No response_

reeswell avatar May 23 '25 08:05 reeswell

I have the exact same error here. Log output identical to @reeswell.

  • WSL 2 on Windows 10
  • @shopify/cli/3.80.7 wsl-x64 node-v24.1.0

jpallard6120 avatar May 26 '25 15:05 jpallard6120

I have the exact same error here. Log output identical to @reeswell.

  • WSL 2 on Windows 10
  • @shopify/cli/3.80.7 wsl-x64 node-v24.1.0

Removing a plugin through shopify plugin reset solved the issue for me.

jpallard6120 avatar May 26 '25 15:05 jpallard6120

I have the exact same error here. Log output identical to @reeswell.

  • WSL 2 on Windows 10
  • @shopify/cli/3.80.7 wsl-x64 node-v24.1.0

Removing a plugin through shopify plugin reset solved the issue for me.

Thank you for your response. However, when I tried shopify plugins reset, it shows "Found 0 plugin" and the issue still persists.

Here's what I've tried:

  1. Ran shopify plugins reset -> Result: "Found 0 plugin"
  2. Completely uninstalled and reinstalled Shopify CLI
  3. Cleared npm cache and configurations

My environment:

  • WSL 2 on Windows 11
  • @shopify/cli/3.53.0
  • Node.js v22.15.1
    • Theme: Liquid theme

reeswell avatar May 27 '25 05:05 reeswell

Do you have docs for the SHOPIFY_HTTP_PROXY? Couldn't find anything.

charlespwd avatar Jun 12 '25 16:06 charlespwd

Looks l like a CLI core/kit issue

charlespwd avatar Jun 12 '25 16:06 charlespwd

Do you have docs for the SHOPIFY_HTTP_PROXY? Couldn't find anything.

#5520

reeswell avatar Jun 19 '25 09:06 reeswell

Same error, How did you finally solve it?

fredmanxu avatar Jul 05 '25 11:07 fredmanxu

Same error, Is there any solution for this?

HowardTangOvO avatar Jul 07 '25 04:07 HowardTangOvO

Same error. Any update for this issue?

cmoaciopm avatar Aug 03 '25 01:08 cmoaciopm

I am also having this problem. I'm commenting so I get notifications if an answer pops up.

wmlutz avatar Aug 08 '25 21:08 wmlutz

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.

P.S. You can learn more about why we stale issues here.

github-actions[bot] avatar Sep 20 '25 03:09 github-actions[bot]

Facing the same issue

ali-raza-saleem avatar Sep 24 '25 15:09 ali-raza-saleem

same issue here

manuel-bbe avatar Oct 13 '25 18:10 manuel-bbe

I haven't found solution for the issue but here's a workaround. Run shopify theme dev and click Share your theme preview instead of http://127.0.0.1:9292 . This has been working smoothly for me. Although you will loose hot reloading and will have to refresh the page manually everytime you want to see your changes.

Less likely fixes:

Install Cloudflare WARP. It resolves DNS through a secure tunnel. Might be useful in the countries with nationwide firewalls which can interfere with DNS resolution.

I was using WSL (ubuntu) in windows for development. WSL was using different network card than my windows. I modified .wsl config to make it use same network card as windows.

Image

ali-raza-saleem avatar Oct 14 '25 05:10 ali-raza-saleem

Thanks all! I think we understand this a little bit better. Some core functionality was added to the CLI to support SHOPIFY_HTTP(S)_PROXY but individual packages (theme in this case) need to implement support for this individually.

  • Original PR: https://github.com/Shopify/cli/pull/5520
  • Hydrogen adopting it: https://github.com/Shopify/hydrogen/pull/2831

We'll be looking into adding better support for this with theme commands in the near future.

graygilmore avatar Oct 23 '25 16:10 graygilmore