Skip to content
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

WSL2 localhost forwarding doesn't seem to work #5304

Closed
omegapaulo opened this issue May 31, 2020 · 4 comments
Closed

WSL2 localhost forwarding doesn't seem to work #5304

omegapaulo opened this issue May 31, 2020 · 4 comments
Labels

Comments

@omegapaulo
Copy link

I am starting to have some problem with the wsl2/Ubuntu-20.04 on windows 2004 May update (insiders slow).

So opening a folder on Ubuntu with VScode and having a single .html file and when I try to open the file in chrome, Firefox, on localhost:5500 using the live server extension I get the can't access this page and I've tried all I know but didn't work. It was working fine before the upgrade to windows 2004. Any help?

@onomatopellan
Copy link

onomatopellan commented May 31, 2020

I just tested and it works on Windows 10 v2004.

Install VSCode 1.45.1 WSL Remote extension 0.44.2.
Open the folder from bash with code .
Install LiveShare extension v5.6.1 in Ubuntu 20.04.
Open index.html in VScode -> right click -> Open with Live Server
Html opens in Microsoft Edge and changes are reflected automatically.

This user also had problems with LiveServer ritwickdey/vscode-live-server#760

@onomatopellan
Copy link

onomatopellan commented Jun 1, 2020

BTW if you have Fast Startup enabled try disabling it. It's known to give localhost problems in WSL2.
https://www.tenforums.com/tutorials/4189-turn-off-fast-startup-windows-10-a.html

@omegapaulo
Copy link
Author

Thanks, @onomatopellan I figured out what's the problem has been, it's all in the file path.
If the folder I open in vscode wsl2 is not inside another folder then all works fine, live reload and everything else, but if the folder I open is inside other folders which will make the path bit longer the vscode in wsl2 will not reload the page on saving at all, I have to manually reload the page. If I am using the vscode in the windows side it works fine.
Do you have any idea why would it behave like that?
I am new to web development so... Kind hard for me to figure these things out even with google

@fch310
Copy link

fch310 commented Jun 19, 2020

Hi guys, i was in the same trouble, i fix it, changing the wsl2 to wsl1,
-first open powershel and run the netx comand "wsl --list --verbose" and you can see the name of your distro and on which version of wsl is running, in my case shows this "* Ubuntu-20.04 Running 1"(name, state and version),
-Now you only need change the wsl version with the next comand "wsl --set-version ", in my case looks like that "wsl --set-version Ubuntu-20.04 1" and will show you the next mensaje "Conversion in progress, this may take a few minutes...
Conversion complete."
-And that is it. my liveserver extension works perfectly , if you want come back to wsl2 only run the last comand only changing the 1 for 2

I hope this can help you guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants