Port Forwarding returns 502 Bad Gateway #28563
Replies: 30 comments 38 replies
-
try running this command in your terminal, here is how to run it, killall node --> https://stackoverflow.com/questions/14790910/stop-all-instances-of-node-js-server, then try to activate the app |
Beta Was this translation helpful? Give feedback.
-
Is this on web or the vscode desktop extension? Are you seeing an error in your server logs? |
Beta Was this translation helpful? Give feedback.
-
@hashfx did you try to switch port protocol(HTTP vs HTTPS) in the ports view in the VSCode? Sometime the service fails to detect a correct protocol, so switching to a correct one manually might help. You can |
Beta Was this translation helpful? Give feedback.
-
I'm having the same issue on web. It seemed to happen after I rebuilt my container |
Beta Was this translation helpful? Give feedback.
-
I am getting the same issue, using my custom-built template (azzazkhan/dev-container). |
Beta Was this translation helpful? Give feedback.
-
I've had a support ticket open with GitHub since April regarding a similar issue: I'm able to consistently reproduce a 502 on Codespaces port forwarding by starting a Codespace that uses Docker Compose in its devcontainer configuration, forwarding a port, and then rebuilding the Codespace. This behavior is quite frustrating as it is often triggered while I'm iterating on my organization's Codespaces configuration, adding to the complexity of the already-time-consuming process of QAing these sorts of changes. https://github.com/jnewland/devcontainer-example/tree/docker-compose-port-forward demonstrates the behavior, or did the last time I tested it. GitHub support has advised me that a workaround for this problem is to stop forwarding the port before rebuilding the Codespace, which I haven't yet successfully validated as I only remember this bug when I experience the 502, not beforehand. Disabling port forwarding and re-enabling it doesn't seem to resolve the issue once you experience it: at this point I generally delete the Codespace and recreate it. |
Beta Was this translation helpful? Give feedback.
-
I am getting the same issue! |
Beta Was this translation helpful? Give feedback.
-
Just happened to me right in the middle if a build! |
Beta Was this translation helpful? Give feedback.
-
I had the same issue, but when I tried:
It is ok. So I used |
Beta Was this translation helpful? Give feedback.
-
Try starting the server on any IPv4:
For yarn:
|
Beta Was this translation helpful? Give feedback.
-
Running |
Beta Was this translation helpful? Give feedback.
-
In general, if you're having this problem, host at |
Beta Was this translation helpful? Give feedback.
-
is this resolved? im running aurelia app in codespace and getting this error |
Beta Was this translation helpful? Give feedback.
-
I have the exact same issue when trying to stand up a default sveltekit application. I've tried all the above suggestions and I get a 502 Gateway error every single time. |
Beta Was this translation helpful? Give feedback.
-
Hi, i have the same issue now... was someone able to fix it afterall? |
Beta Was this translation helpful? Give feedback.
-
with angular , running |
Beta Was this translation helpful? Give feedback.
-
For anyone using Fix: |
Beta Was this translation helpful? Give feedback.
-
For anyone using
|
Beta Was this translation helpful? Give feedback.
-
"dev": "vite dev --host", |
Beta Was this translation helpful? Give feedback.
-
If you're using Vite you can change the following in your package.json now you can run the following from your terminal |
Beta Was this translation helpful? Give feedback.
-
add |
Beta Was this translation helpful? Give feedback.
-
Try changing both the host and the port, as it may not work on all ports |
Beta Was this translation helpful? Give feedback.
-
I am trying to develop a web application based on Angular in Codespace. When I did "npm run start", I got the local host URL in the terminal. After clicking on it I got a blank loading page which supposes to be the initial start page of angular if I run this same command locally. |
Beta Was this translation helpful? Give feedback.
-
I just got this same error while using npm run dev for a simple react app I am creating |
Beta Was this translation helpful? Give feedback.
-
My vite project worked after changing the port from
|
Beta Was this translation helpful? Give feedback.
-
Killing the running processes worked for my React Project. Stopping and starting a codespace - GitHub Docs
|
Beta Was this translation helpful? Give feedback.
-
Hi all. I kept running into this 502 bad gateway error when i was in my The solve for this is to just stop the codespace, but restart it while you are on your newly created branch. Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
In my case i get 502 bad gateway |
Beta Was this translation helpful? Give feedback.
-
I also saw this issue with spring boot and port forwarding -- and this was also intermittent, especially when first creating the codespace (and even after multiple restarts from then). |
Beta Was this translation helpful? Give feedback.
-
A 502 Bad Gateway error typically occurs when a server acting as a gateway or proxy receives an invalid response from an inbound server. In your case, it seems like the issue is between your React app running on port 3000 and your Express API running on port 5000. In client side, you can add proxy in package.json: And maybe you need to check nginx setting for them. server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /api/ {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
} |
Beta Was this translation helpful? Give feedback.
-
When running a react app on port 3000, and Express API on port 5000 gives 502 Bad Gateway Error.
Beta Was this translation helpful? Give feedback.
All reactions