ritwickdey / live-server-web-extension

It makes your existing server live. This is a browser extension that helps you to live reload feature for dynamic content (PHP, Node.js, ASP.NET -- Whatever, it doesn't matter)
https://chrome.google.com/webstore/detail/live-server-web-extension/fiegdmejfepffgpnejdinekhfieaogmj/
MIT License
808 stars 342 forks source link

Live Server not working in WSL 2 #53

Open pabloherrero1986 opened 4 years ago

pabloherrero1986 commented 4 years ago

Live Server does not work in WSL 2. When I click on "Go Live", the browser does not open. If I access through the browser by entering the address http://127.0.0.1:5500/, it doesn't open either.

Under Windows 10 without WSL2, clicking on "Go Live" automatically opens the browser.

Is there a way to fix it?

Alpaca92 commented 3 years ago

I'm going through the same error, did anyone solve it?

pabloherrero1986 commented 3 years ago

No :(

Noxdor commented 3 years ago

It was working for me just find and then today I had the same problem as you guys. So I did what fixes actually most of the problems, I restarted my device. Now it works again, crazy! Maybe you guys are trying it too after having your device in sleep/stand-by for a longer time?

Furthermore, while it didn't work to connect to the live-server through my Windows browser, it did by connecting it through an XServer. I have one installed in Windows and after I started it, the live-server started in VS Code in WSL automatically opened the browser window in the installed browser in my WSL. (Whenever I say WSL I mean WSL2 of course)

Anyhow, after a restart of my device I could connect again without any problems to the live-server through my Windows browser, both with localhost:xxxx and 127.0.0.1:xxxx

Hope I could help and it fixes the problem for you too.

zaher-aa commented 3 years ago

Live Server does not work in WSL 2. When I click on "Go Live", the browser does not open. If I access through the browser by entering the address http://127.0.0.1:5500/, it doesn't open either.

Under Windows 10 without WSL2, clicking on "Go Live" automatically opens the browser.

Is there a way to fix it?

Same problem bro, but when I copy the address http://127.0.0.1:5500/, it works fine.

azifnazar commented 1 year ago

This can be achieved using the wslview utility and setting the $BROWSER environment variable to 'BROWSER=wslview'. wslview is a WSL browser emulator that can help you open links in the default Windows browser or open files on Windows from WSL.

The utility is pre-installed by default when using the latest Ubuntu releases on WSL but can also be added/updated on other Linux distros by installing wslu which provides a collection of utilities for Windows 10 Linux Subsystem.

Refer to the Github repository at wslu - A collection of utilities for WSL for the installation instructions applicable to your WSL Linux environment. checked and working well, source: https://support.cloud.engineyard.com/hc/en-us/articles/4405614113691-Setting-the-default-browser-when-using-EYK-CLI-on-WSL#:~:text=In%20order%20for%20the%20authentication%20process%20to%20succeed%2C,browser%20or%20open%20files%20on%20Windows%20from%20WSL.