vscode-live-server icon indicating copy to clipboard operation
vscode-live-server copied to clipboard

Live Reload not working in Remote Window (WSL)

Open addmanrcace opened this issue 4 years ago • 25 comments

I'm submitting a...

[x ] Regression (a behavior that used to work and stopped working in a new release)
[x ] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->
[ ] Feature request
[ ] Documentation issue or request
[ ] Other: <!-- Please describe: -->

Current behavior

When using VS Code as a remote window connected to WSL (Ubuntu 18.04) the live reload feature of Live Server does not work.

Expected behavior

Live reload to work as it does when not in a remote window connected to WSL.

Environment

Browser:

- [x] Chrome (desktop) version 80.0.3987.163
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] IE version XX
- [ ] Edge version XX

For Tooling issues:

- Live Server: 5.6.1 <!-- Check which version is installed --> 
- Platform: Windows | Ubuntu 18.04 WSL  <!-- Mac, Linux, Windows -->
- Visual Studio Code: 1.45.0-insider <!-- `code --version` -->

Others

When not using a remote window, the live reload feature works.

addmanrcace avatar Apr 14 '20 18:04 addmanrcace

I' m having the same issue too with Ubuntu 20.04 LTS WSL2 on windows 10 where auto refreshing doesn't work. Works fine fine when not connected to WSL. Whatever the bug is it is also affects Parcel.

Has anyone found a solution for this?

andyboltondev avatar Aug 12 '20 18:08 andyboltondev

The problem seems still present. I have the same issue: Ubuntu 18.04 LTS (WSL2) Windows 10 Pro Chrome Version 87.0.4280.88 (I tried defining the chrome.exe path as the BROWSER environment variable in .brashrc but no success)

The same happens if I try this with the npm version of live server

Any work around?

maxbonaparte avatar Dec 11 '20 19:12 maxbonaparte

it's working here. live server 5.6.1,wsl2, browser run in windows host.

jan4984 avatar Jul 30 '21 08:07 jan4984

Im having the same issue too in Arch linux (WSL2) using firefox developer edition.

Jjaraa avatar Aug 15 '21 22:08 Jjaraa

I solved it by looking for the local ip of my machine using ifconfig in the terminal, copy the ip, paste it in my browser and then :5500 (live server)

IvanSerranoGit avatar Sep 02 '21 23:09 IvanSerranoGit

To fix this issue go to Settings make sure you're under Remote[WSL:"your linux distro"] and modify the Live Server>Settings: Advance Custom Browser CMD Line click edit in settings.json it should look like this: "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" change the path a needed for Firefox, Edge etc.

It seems the extension is looking within the OS for the browser as installing linux chrome also works, but under wsl its not too good so Id suggest th above fix or maybe adding chrome to the path for linux

ericuxnyc avatar Sep 14 '21 15:09 ericuxnyc

To fix this issue go to Settings make sure you're under Remote[WSL:"your linux distro"] and modify the Live Server>Settings: Advance Custom Browser CMD Line click edit in settings.json it should look like this: "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" change the path a needed for Firefox, Edge etc.

It seems the extension is looking within the OS for the browser as installing linux chrome also works, but under wsl its not too good so Id suggest th above fix or maybe adding chrome to the path for linux

Thanks from Brazil.

dnlrgs avatar Dec 04 '21 19:12 dnlrgs

To fix this issue go to Settings make sure you're under Remote[WSL:"your linux distro"] and modify the Live Server>Settings: Advance Custom Browser CMD Line click edit in settings.json it should look like this: "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" change the path a needed for Firefox, Edge etc.

It seems the extension is looking within the OS for the browser as installing linux chrome also works, but under wsl its not too good so Id suggest th above fix or maybe adding chrome to the path for linux

Thanks from México!

chuy-labs avatar Feb 04 '22 01:02 chuy-labs

I've tried to implement what you said above similar time but it still doesn't fixes. The 2nd method which said about adding chrome to path for linux, how do i do that? any idea?

snehel4510 avatar May 03 '22 19:05 snehel4510

Después de unas horitas, encontré esta solución: Vaya a Configuración, asegúrese de estar en Remoto [WSL: "su distribución de Linux"] y modifique Live Server> Configuración image

Se modificara: "liveServer.settings.port": 5500 Por defecto esta en el port 5500. Puedes cambiarlo a otro en mi caso solo puse 5501 image

Asegúrate que en la parte inferior derecha te salga el nuevo valor del puerto cuando lo ejecutes: image

DanielHenryL avatar May 14 '22 05:05 DanielHenryL

To fix this issue go to Settings make sure you're under Remote[WSL:"your linux distro"] and modify the Live Server>Settings: Advance Custom Browser CMD Line click edit in settings.json it should look like this: "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" change the path a needed for Firefox, Edge etc.

Based on this answer, i've prepared the config to support 1 browser, you just need to uncomment your preffered browser:

{
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Users/<<USERNAME>>/AppData/Local/Programs/Opera/opera.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Users/<<USERNAME>>/AppData/Local/Programs/Opera GX/opera.exe"
}

Note - To reach the Opera browsers just rename <<USERNAME>> with your current username. Note² - The Firefox folder may vary depending on the source you've installed.

LeDragoX avatar May 15 '22 15:05 LeDragoX

Hola muy buenas noches, cordial saludo a todos tengo una pregunta, VS CODE bien puedo visualizar los codigo que estoy creando para paginas de practica, pero me aparece un problema que cuando yo le doy en live server aparece port 500 y deberia aparecer la pagina de practica en una ventana de google chrome, pero no me aparece nada ni errores ni nada es algo extraño es la primera vez que me pasa eso como soluciono eso?

Tigre315 avatar Jul 01 '22 01:07 Tigre315

Hi, I've managed to finally get this to work:

  • Before that I had mistakenly linked the [liveServer.settings.AdvanceCustomBrowserCmdLine] to 'Program Files' when my browser was installed in 'Program Files (x86)', afterwards it managed to pop out and load the html, however it was not 'live'....meaning I still had to refresh to see any changes.

  • After shifting my working files (which were in D drive) to the same directory (C drive /desktop) that the browser was installed in, it seems to be running fine.

-However, if you were to run it on the local drive ( not in WSL ) do note that the [liveServer.settings.AdvanceCustomBrowserCmdLine] directory might have to be edited for it to work on the local drive again, since it's linked differently on WSL( /mnt/c/Program Files ) instead of local(C:\Program Files .....)

Jermaine-ye avatar Jul 08 '22 06:07 Jermaine-ye

To fix this issue go to Settings make sure you're under Remote[WSL:"your linux distro"] and modify the Live Server>Settings: Advance Custom Browser CMD Line click edit in settings.json it should look like this: "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" change the path a needed for Firefox, Edge etc.

Based on this answer, i've prepared the config to support 1 browser, you just need to uncomment your preffered browser:

{
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Users/<<USERNAME>>/AppData/Local/Programs/Opera/opera.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Users/<<USERNAME>>/AppData/Local/Programs/Opera GX/opera.exe"
}

Note - To reach the Opera browsers just rename <<USERNAME>> with your current username. Note² - The Firefox folder may vary depending on the source you've installed.

This worked for me, I was having a hell of a time trying to figure this out. Thank you

Smoothie17 avatar Jul 29 '22 15:07 Smoothie17

To fix this issue go to Settings make sure you're under Remote[WSL:"your linux distro"] and modify the Live Server>Settings: Advance Custom Browser CMD Line click edit in settings.json it should look like this: "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" change the path a needed for Firefox, Edge etc.

Based on this answer, i've prepared the config to support 1 browser, you just need to uncomment your preffered browser:

{
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Users/<<USERNAME>>/AppData/Local/Programs/Opera/opera.exe"
  //"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Users/<<USERNAME>>/AppData/Local/Programs/Opera GX/opera.exe"
}

Note - To reach the Opera browsers just rename <<USERNAME>> with your current username. Note² - The Firefox folder may vary depending on the source you've installed.

woked like charm

please add brave

"liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe"

m-a-mohsen avatar Oct 09 '22 10:10 m-a-mohsen

To fix this issue go to Settings make sure you're under Remote[WSL:"your linux distro"] and modify the Live Server>Settings: Advance Custom Browser CMD Line click edit in settings.json it should look like this: "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" change the path a needed for Firefox, Edge etc.

It seems the extension is looking within the OS for the browser as installing linux chrome also works, but under wsl its not too good so Id suggest th above fix or maybe adding chrome to the path for linux

Worked liked a charm.

rafaover avatar Oct 30 '22 02:10 rafaover

To fix this issue go to Settings make sure you're under Remote[WSL:"your linux distro"] and modify the Live Server>Settings: Advance Custom Browser CMD Line click edit in settings.json it should look like this: "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" change the path a needed for Firefox, Edge etc.

It seems the extension is looking within the OS for the browser as installing linux chrome also works, but under wsl its not too good so Id suggest th above fix or maybe adding chrome to the path for linux

Thanks, It worked for me with Edge.

AlejoC98 avatar Jan 08 '23 10:01 AlejoC98

Hola, tengo windows 11, y trabajo en ubuntu 20.04, tengo este mismo problema, cuando hago correr el live server, se abre el navegador con el archivo, y a medida que hago cambios y guardo, los mismos se ven reflejados en el navegador. Lo que no puedo hacer es ejecutar con F5 o crtl F5, porque ahi solo abre el navegador y muetra la ubicacion del archivo y que no encuentra al mismo. Alguno me podra ayudar? estoy segurp que es algo en la configuracion. Gracias

Fpaganoni avatar Jan 16 '23 21:01 Fpaganoni

To fix this issue go to Settings make sure you're under Remote[WSL:"your linux distro"] and modify the Live Server>Settings: Advance Custom Browser CMD Line click edit in settings.json it should look like this: "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" change the path a needed for Firefox, Edge etc.

It seems the extension is looking within the OS for the browser as installing linux chrome also works, but under wsl its not too good so Id suggest th above fix or maybe adding chrome to the path for linux

Thanks from Uruguay!

Santi3948 avatar Feb 08 '23 09:02 Santi3948

To fix this issue go to Settings make sure you're under Remote[WSL:"your linux distro"] and modify the Live Server>Settings: Advance Custom Browser CMD Line click edit in settings.json it should look like this: "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" change the path a needed for Firefox, Edge etc.

It seems the extension is looking within the OS for the browser as installing linux chrome also works, but under wsl its not too good so Id suggest th above fix or maybe adding chrome to the path for linux

Thanks from India!

sikehish avatar Apr 04 '23 10:04 sikehish

For anyone wondering for firefox : "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"

sikehish avatar Apr 04 '23 10:04 sikehish

To fix this issue go to Settings make sure you're under Remote[WSL:"your linux distro"] and modify the Live Server>Settings: Advance Custom Browser CMD Line click edit in settings.json it should look like this: "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" change the path a needed for Firefox, Edge etc.

It seems the extension is looking within the OS for the browser as installing linux chrome also works, but under wsl its not too good so Id suggest th above fix or maybe adding chrome to the path for linux

Thanks alot!

hoahamho avatar Jun 09 '23 06:06 hoahamho

Um dieses Problem zu beheben, gehen Sie zu „Einstellungen“, stellen Sie sicher, dass Sie sich unter „Remote“ [WSL: „Ihre Linux-Distribution“] befinden, und ändern Sie „Live Server“ > „Einstellungen: Erweiterte benutzerdefinierte Browser-CMD-Zeile“. Klicken Sie in „settings.json“ auf „Bearbeiten“. Es sollte so aussehen: „liveServer“ . .settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" den für Firefox, Edge usw. benötigten Pfad ändern.

Es scheint, dass die Erweiterung im Betriebssystem nach dem Browser sucht, da die Installation von Linux Chrome auch funktioniert, aber unter WSL ist es nicht so gut, also würde ich die obige Korrektur vorschlagen oder vielleicht Chrome zum Pfad für Linux hinzufügen

Thanks mate you are awesome 🙌

BenFielmann avatar Jun 26 '23 10:06 BenFielmann

For anyone wondering for firefox : "liveServer.settings.AdvanceCustomBrowserCmdLine": "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"

Amazing, thanks!

senachary avatar Jul 11 '23 17:07 senachary

To fix the problem I simply installed the WSL extension in VSCODE. I opened the terminal normally and within the index.html file I used the standard shortcut to open the Live Server.

Hot reload worked normally. However, I haven't tested it for a long time in my applications, so I leave a warning sign for anyone who uses the method.

A big hug from Brazil!!

image

gustavomarim avatar Oct 27 '23 12:10 gustavomarim

I solved it by looking for the local ip of my machine using ifconfig in the terminal, copy the ip, paste it in my browser and then :5500 (live server)

Thank you, this is what worked for me.

studiozandra avatar Dec 08 '23 06:12 studiozandra