microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.62k stars 28.67k forks source link

Port forwarding fails after codespace restart, or rebuild #228676

Open mhitza opened 4 days ago

mhitza commented 4 days ago

I have an example repository where this issue happens. https://github.com/mhitza/codespace-port-forwarding-bug (a devcontainer, a compose file and a Dockerfile which uses the php:8.1-apache as base image). Apache runs in the background and this is the base container in which the codespace user operates.

First time the codespace is built, the port 80 forwarded port will work. Opened in a new tab, a forbidden page should be shown (because this is a minimal reproduction proof on concept and I've included no additional files for Apache to render).

Once the codespace is left (closed), and later returned to it, or the container is rebuilt, the port forwarding will no longer work, and a 502 response will be what I will see instead. However, if I manually remove the port forwarding rule, and add it again manually (just typing port 80 in the field and hitting enter), the forwarding will work once again, until I do any of the previously mentioned actions.

Version: 1.93.1 Commit: 38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40 User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0 Embedder: codespaces

alexr00 commented 3 days ago

Thanks for creating a minimal repro! I get a 404 when I go to https://github.com/mhitza/codespace-port-forwarding-bug. Is it private?

mhitza commented 3 days ago

@alexr00 sorry about that, made it public now.