-
Notifications
You must be signed in to change notification settings - Fork 839
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
Local sites running in WSL2 not accessible in browser #5298
Comments
Do they work with https://docs.microsoft.com/en-us/windows/wsl/compare-versions#additional-networking-considerations |
Nope, on some scripts this throws an error that |
That hint sounds a lot like Fast Startup. I always disable it and had no localhost problems so far. |
Awesome, that's working now! At least I have a workaround for now (that doesn't require me restarting my computer as soon as I turn it on) I wonder what the issue is that's making it not work when computer has fast booted |
To avoid disabling Fast Startup, restarting WSL as pointed in #4636 worked for me ( |
same problem here on 19640.mn_release.200530-1731 on Surface Pro X. wsl --shutdown doesn't work |
Ran into this issue today. Seems like 127.0.0.1 doesn't work at all. |
@krojew |
I'm not using Windows Defender. |
Until the bug is fixed, make sure you disable Fast Startup. |
I had to revert back to WSL1. |
Had the issue, fixed it temporarily (until bug is fixed) by disabling Fast Startup as recommended above. |
Didn't work for me, I fixed it by writing a little bash script, which modifies the windows host file everytime wsl is starting. Works perfectly :) |
@matze19999 Same here - would you mind providing your bash script? Thank you |
WSL2 seems to change localhost IP on every boot. Anybody found a decent "workaround"? |
Thats the script. Make sure your user has the permission to modify / create files in the "/Windows/System32/drivers/etc/" folder because sed will create a temp file in this directory. Run this script everytime you start wsl and you'll be fine. |
Sorry for dropping in, but might this bug also cause an openssh-server running in WSL to not be available from the outside (beyond localhost)? I've set up ssh on port 2222: In WSL/Ubuntu 20 $ netstat -an
Proto ... Local Address Foreign Address State
tcp 0.0.0.0:2222 0.0.0.0:* LISTEN In PowerShell on the same host $ netstat -an
Proto ... Local Address Foreign Address State
TCP 127.0.0.1:2222 0.0.0.0:0 LISTENING When I try to ssh from my Mac I get a connection timeout. Not even Fastboot disabled, Firewall Inbound Rule for TCP 2222 active. Out of ideas. |
Same problem here with exposed port on docker container. |
@Scarysize @matze19999 That's another issue. To access WSL2 from other computer you need port forwarding. See #4150 (comment) |
@onomatopellan Oh wow thanks, was googling around for hours but did not find that comment. I'll give it a try! |
I have the same problem here. I disabled fast startup. Reverting back to WSL 1 is the only thing that works. |
This one went fixinbound on June 16, so conservatively /fixed 20180. There is no repro in the OP to actually confirm. For users still experiencing problems that may seem related on 20180 or better, you are going to want one of those (a repro with CLI steps that can be run) on the new submission. |
This bug or feature request originally submitted has been addressed in whole or in part. Related or ongoing bug or feature gaps should be opened as a new issue submission if one does not already exist. Thank you! |
When will this be available for non insider Users? |
Probably with 20H2 |
Not sure if this will help anyone but I had the same with firebase and React. The issue turned out to be:
My fix was to remove the 127.0.0.1 alias from /etc/hosts, and add 'localhost' to the ::1 line - after that it worked like a charm, though that could have side effects in other software. |
Nice. I don't know how you figured out it was because of Fast Startup, but disabling that fixed it for me. And just to add a data point, I have been running services on WSL2 with no issue for over a month now. Then today, out of nowhere, I couldn't access any of my services via localhost (PostgreSQL, node, etc...). I cannot remember the computer shutdown or rebooted before this happen, but I guess that must have happened right? But that really doesn't make sense because I have shutdown and restarted many times in the past and WSL2 always came back just fine. Anyways, thanks for the tips. |
I'm in the same situation, except for the fact that I disabled Fast startup a long time ago. |
This is helpful for me,thanks. |
I have the same issue. Run |
The same issue for me, but it didn't work again after disabling Fast Startup. |
Why is this issue closed? The problem still persists. |
Depending on your use case and whether you are on build ~20180 or better, you probably want to subscribe still-open #4851 #4150, others. This issue went fixinbound in June 2020. Or opening a thread in discussions for community suggestions regarding work-arounds for specific use cases is always welcome. |
When starting a site/app locally on my computer in WSL 2 ( Ubuntu 20.04 LTS (GNU/Linux 4.19.84-microsoft-standard x86_64)), the browser won't connect to the local server.
This happens every time I start my computer (has been happening for a weekish now), but only when starting after the computer has been shut down. If I restart the computer, the local servers work fine
Please fill out the below information:
Your Windows build number: (Type
ver
at a Windows Command Prompt)Microsoft Windows [Version 10.0.19041.264]
What you're doing and what's happening:
Running a local server for dev site. Happens regardless of site. eg.:
What's wrong / what should be happening instead:
I should be able to access the apps at the provided local URL (
localhost:8080
for eleventy andlocalhost:8000
for Gatsby), but when loading the page in the web browser it says it's unable to connect (in both Firefox and Edge)Strace of the failing command, if applicable: (If
some_command
is failing, then runstrace -o some_command.strace -f some_command some_args
, and link the contents ofsome_command.strace
in a gist here).The text was updated successfully, but these errors were encountered: