In this article, we will look at some things you should be aware of before you decide to use WSL as your main development environment. First of all, what is WSL? WSL is a technology created by Microsoft to run Linux systems on top of your Windows operating system. It has a better performance than running an actual virtual machine and is tightly integrated with Windows, making it easy to share resources seamlessly between both systems. This is a great tool for people (e.g. developers) who need to work in Linux environments but still need the flexibility of accessing regular desktop applications such as Microsoft Office, Adobe suite, or even PC games as the alternatives on Linux are not-so-great.
About four months ago, I did a fresh install of my Windows OS and decided to go all in with WSL. I installed my Nodejs runtime in WSL and instead of using Git bash, I decided to go with Git which came preinstalled in my WSL Linux environment. So in this article, I will share my experience so far (mostly the negative ones), hoping you will get a lot of value from it if you're considering switching as well.
I broke the problems down into 3 categories:
Networking was the biggest issue I faced with WSL. Say you have a server/service running in WSL, you can easily access it in Windows from
:[port-number] , because all ports in WSL are mapped to the ports on Windows, but this isn't true the other way around. You can't access services running in Windows from WSL using
My NodeJS server was running in WSL and had to access a database service (MongoDB) running in Windows. The connection failed because WSL doesn't have access to "localhost", meaning services running in Windows cannot be accessed directly from WSL. The solution to this problem was to make the MongoDB service accessible on all public network interfaces by running the command
mongod.exe --bind_ip 0.0.0.0 each time I had to start the service. Optionally, you can still configure the port you are accessing to accept inbound traffic in the Windows firewall. To access the service from WSL, you will have to use your PC's IP address + the service port number instead of using
localhost:27017. It should look something like this
192.168.0.5:27017 for example.
N/B: I am working with WSL2 which has a different architecture from WSL1. And from my research, WSL1 did not have this issue.
Accessing files from the terminal was another issue I came across while using WSL. In WSL you can easily access your Windows drives from the
But if you have to access a file in WSL from Windows(command prompt, PowerShell), things become tricky as there isn't a direct way to do so (or at least I wasn't able to find one). But I came up with a hacky way of doing this, as follows:
From Windows Explorer, navigate to the WSL directory you wish to access.
User the shortcut combination
Right Clickto see the option "Open PowerShell window here"
Click on it and PowerShell will be open in that WSL directory.
Since I installed WSL, I noticed my PC began to lag and the fans will frequently spin up especially when I am working in a VS Code WSL environment. Sometimes it would get very slow and unbearable that I'd have to restart my PC. My current PC configuration is a 6th gen Core i7 with 8GB ram and 500GB storage and I've used it for the past 2 years without facing any latency issues until I started working with WSL. This might not be an issue for you if you have a newer PC with greater specs, I just wanted to mention this point too.
While WSL has its drawbacks, I found it to be very helpful and had fun using it. I will keep on using it for my Linux tasks as I think it's a better alternative to dual booting. I love working with Windows and Linux and having both in one package is really awesome. I hope Microsoft continues to improve WSL!