-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port forwarding not working (ERR_EMPTY_RESPONSE in browser) #764
Comments
Running in Jekyll in verbose mode shows when a client connects (for ex. when using |
Hmmm, I tried it on a different port (8123) and it seems to work. Is there something weird about 4000? |
Did you have something listen on your local 4000? In that case the forwarding will pick a random port locally, there is a notification telling you which port it ended up with. |
No, there was nothing local and I used the "open in browser" button in the forwarding notification. What's weird is I was sure it worked the first time, then it broke - I think when I tried changing it to using appPort in JSON. But now even after rebuilding the container, rebooting, and not having it in I'll try another reboot and test again later just to be sure. |
It's working now :/ If I see it again, I'll try and do some more digging. If there's anything you think I should try/check, let me know. |
Ok, there's definitely something not working right here. I'm seeing it again on a completely different image. I'm using Interestingly, if I stop the container/close VS Code, then I get a connection error (eg. nothing is bound to the port), but when I open VS Code, let the container start, then forward the port (which shows 8787), then I get ERR_EMPTY_RESPONSE. So it definitely seems like the port forwarding is doing something, but it's not working correctly. I'm on Windows 10 Pro. Dockerfile just looks like:
devcontainer.json looks like this:
I've tried both with Restarting Docker did not help. |
Hmm, interestingly using wget from inside the container I get "connection refused", so now I'm wondering if RStudio is even running properly (though if it's not, I'm not sure why 8787 shows up in the port forwarding list... is that just a list of what the container exposes, are is it things that are definitely open?). Running |
I found the full command VS Code is running in the container log, and I added
This all worked fine. So is VS Code's port forwarding different to doing |
The port forwarding shows the list of currently open ports and uses tunneling through Do you see the empty response only when inside the container you get the connection refused? (The port forwarding can't "forward" the refused connection because it has to accept the connection on the host machine first before it can do/attempt the actual forwarding.) |
I am also getting the same problem trying to run the Webpack development server in the VSCode terminal after connecting to the Upon further investigation, it works just fine if I
But when I curl from outside the container I get an empty response:
EDIT: I fixed it! Turns out I had to enable the Webpack dev server to be accessed outside localhost (which is the default and would explain why it would only be accessible from inside the container). As per this issue: moby/moby#2522, I passed @DanTup I think if you pass |
@jswny That is indeed a limitation that Docker's port forwarding has which you get when using |
Sorry for the delay. I can repro this issue now, but indeed I see connection refused inside (in the terminal) when I'm seeing empty_response from outside. I can't figure out what's going wrong though - the fact that the port showed up in VS Code's "forward" list suggests that something is bound to the port, and if I run the docker container manually with a Docker port binding everything works. Any ideas? Here's my devcontainer config:
I'm no longer using my own Dockerfile, just the
|
It might need to run something as part of its |
Aha! That didn't seem to make any difference at first (I deleted all my docker containers and images except the rocker/verse image assuming that'd clear all state), but running "rebuild container" it seems like that did fix it. I'm not sure why when I originally hit this it seemed to work "sometimes" though. It's long enough ago that I can't say for certain I didn't get confused with launching it from the command line. If this is a known limitation, then there might be nothing to do here (though it'd obviously be nice if the user didn't need to know when this applied :-)). |
The problem we were trying to solve with overriding CMD/ENTRYPOINT by default is that these would oftentimes start the server you want to work on and our assumption is that you would rather start that manually (in debug mode) once the project is set up (e.g., with npm install). Apparently that assumption doesn't hold here. |
Yeah, this use case was probably a bit weird. When I just started, I planned to use VS code to edit R files and run them (in the usual way you might use this container support), but it turned out that R had a nice web IDE so I switched to a container that included that and essentially ended up trying to use VS Code just as a convenient way to start the docker container and mount a local folder into it (but wasn't actually using VS Code for the editing). This was obviously pointless, so I then switched to just using a PoSh alias that ran Docker directly with the flags (that I stole from VS Code log) to mount the folder directly. So the example above doesn't seem like a particularly valid use case. I don't know if there are "more-valid" workflows that would be hit by this though, so I'll leave it to you to decide whether it's an issue (or how much of an issue). In any case, it may be worth expanding on the docs for |
@DanTup We just updated docs to include an explicit mention of |
LGTM :-) |
I ended up here looking for why |
@Karrq Rebuild Container is mentioned in many different places. Where did you expect to see it but didn't find it? |
you are right. I was completely blind... It's written in multiple places! Maybe not enough emphasis? Make sure you rebuild your container if you edit your configurationwould probably have done it for me... |
I updated this PR microsoft/vscode-docs#2901 to add it in a few more spots. We're also discussing prompting you about whether you want to rebuild if you reload after making modifications which likely is the right long term fix. I'm going to close this issue since the original feedback is now live in the docs. |
I have a Dockerfile in .devcontainer like this:
If I load my project in the container and then run
jekyll serve
in the shell, I see:If I then run "Forward port from container" it correctly lists 4000 and claism to forward it, however when I open in my browser I get:
However if I open another terminal window and run
curl localhost:4000
then I see the HTML output as expected.I don't know if it's related, but there's this in the developer tools console.
The text was updated successfully, but these errors were encountered: