Repository navigation
Description
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
verat 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.:
// Eleventy Site
$ npx @11ty/eleventy --serve
[Browsersync] Access URLs:
--------------------------------------
Local: http://localhost:8080
External: http://172.25.237.22:8080
--------------------------------------
UI: http://localhost:3001
UI External: http://localhost:3001
--------------------------------------
[Browsersync] Serving files from: _site
[Browsersync] Watching files...
// Gatsby site
$ gatsby develop
success run queries - 5.329s - 9/9 1.69/s
DONE Compiled successfully in 2177ms 2:10:28 PM
⠀
I Netlify CMS is running at http://localhost:8000/admin/
⠀
You can now view climate-clever in the browser.
⠀
http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
http://localhost:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use gatsby build
⠀
success Building development bundle - 3.192s
-
What's wrong / what should be happening instead:
I should be able to access the apps at the provided local URL (localhost:8080for eleventy andlocalhost:8000for 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_commandis failing, then runstrace -o some_command.strace -f some_command some_args, and link the contents ofsome_command.stracein a gist here).


Activity
onomatopellan commentedon May 30, 2020
Do they work with
--host 0.0.0.0as argument?https://docs.microsoft.com/en-us/windows/wsl/compare-versions#additional-networking-considerations
amykapernick commentedon Jun 1, 2020
Nope, on some scripts this throws an error that
--hostisn't a recognised parameter, and on the rest the site starts properly, but the URLs still aren't accessibleonomatopellan commentedon Jun 1, 2020
That hint sounds a lot like Fast Startup. I always disable it and had no localhost problems so far.
https://www.tenforums.com/tutorials/4189-turn-off-fast-startup-windows-10-a.html
amykapernick commentedon Jun 2, 2020
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
gsalamin commentedon Jun 3, 2020
To avoid disabling Fast Startup, restarting WSL as pointed in #4636 worked for me (
wsl --shutdown).matze19999 commentedon Jun 10, 2020
same problem here on 19640.mn_release.200530-1731 on Surface Pro X. wsl --shutdown doesn't work
krojew commentedon Jun 16, 2020
Ran into this issue today. Seems like 127.0.0.1 doesn't work at all.
WozniakMac commentedon Jun 16, 2020
Kamil Rojewski (@krojew)
Try to add
C:\Windows\System32\wsl.exetoWindows Defender Firewallkrojew commentedon Jun 16, 2020
I'm not using Windows Defender.
onomatopellan commentedon Jun 16, 2020
Until the bug is fixed, make sure you disable Fast Startup.
If you still have localhost forwarding problems with Fast Startup disabled then it's another issue.
krojew commentedon Jun 16, 2020
I had to revert back to WSL1.
ojacques commentedon Jul 3, 2020
Had the issue, fixed it temporarily (until bug is fixed) by disabling Fast Startup as recommended above.
Alternatively, opening a Powershell script, and issue
wsl --shutdown, re-open WSL terminal brought me back to business every-time.10 remaining items
agarwalvaibhav0211 commentedon Aug 11, 2020
When will this be available for non insider Users?
bogdan-calapod commentedon Sep 3, 2020
Probably with 20H2
johnorourke commentedon Sep 19, 2020
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.
vinhboy commentedon Nov 19, 2020
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.
Lucide commentedon Nov 22, 2020
I'm in the same situation, except for the fact that I disabled Fast startup a long time ago.
I have a Ubuntu 20.4 WSL2 vm that last week became unreachable by ssh. For the first time, restarting the pc did not fix the issue. No logged firewall interference.
wsl --shutdownrestart is no good either, nor is a service restart.Sometimes, but it's becoming increasingly rare, I find the connection to be working until the next reboot.
Ugly to get back to a plain vm, after having a taste of the deeply integrated features WSL1. In the name of progress..
ledtest commentedon Nov 24, 2020
This is helpful for me,thanks.
Please follow this step:
1.No need to close your firewall
2.Open a Powershell,run
wsl --shutdown3.Re-open WSL,run
sudo python3 manage.py runserver4.Open your browser,enter
http://127.0.0.1:8000,you will see it works correctly.danhphan commentedon Dec 26, 2020
I have the same issue. Run
wsl --shutdownin Powershell and then open Ubuntu 20.04 again work for me.lrphael commentedon Dec 31, 2020
The same issue for me, but it didn't work again after disabling Fast Startup.
95lux commentedon Jan 12, 2021
Why is this issue closed? The problem still persists.
therealkenc commentedon Jan 13, 2021
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.