'Live Server extension is not auto-reloading with WSL2
I'm having an issue with the Live Server extension for VS Code (https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer). I'm using WSL 2 for my programming and I have my GitHub repos saved in the Linux filesystems:
\wsl$\Ubuntu\home\myName\Files\GitHub\CSS-My-Site
The issue is that when I make any changes in my project and save, the web page does not automatically reload the way it's supposed to. Now, when I initially run Live Server it does indeed open up my browser and display my page. It just doesn't update after that, I have to refresh manually.
I'm guessing it has something to do with WSL2 because if I move my project folder to my Windows desktop, Live Server works perfectly. I've tried 3 different projects from within the Linux filesystems and none of them update automatically. I've moved all 3 to my desktop, and they auto-refresh just fine. I've also uninstalled and reinstalled the extension, and reinstalled VS Code as well.
I've gone through a couple of posts but none of them seem to have my specific issue. The 2 most relevant were:
I am running Mullvad VPN and also tried turning it off and the issue persisted. My system information is below:
Edition Windows 10 Home
Version 20H2
Installed on 11/13/2020
OS build 19042.630
Experience Windows Feature Experience Pack 120.2212.31.0
Solution 1:[1]
It seems WSL doesn't support live reload if the file is in another OS. Please refer the GitHub issue. The solution is to keep the source and execution in the same place.
Solution 2:[2]
I solved my problem just by changing the extension, now I use "Five Server"
Solution 3:[3]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ben3000 |
Solution 2 | Herison S. |
Solution 3 | Iván Serrano |