Enable Systemd in WSL 2

Note: See footnote at bottom of this answer for background on this Community Wiki. There are several possible paths to enabling Systemd on WSL2 (but not WSL1). These are summarized here, with more detail provided below. Option 1: Upgrade WSL to the latest application release (if supported by your system) and opt-in to the Systemd … Read more

Show matplotlib plots (and other GUI) in Ubuntu (WSL1 & WSL2)

Ok, so I got it working as follows. I have Ubuntu on windows, with anaconda python 3.6 installed. Download and install VcXsrv or Xming (X11 for Windows) from sourceforge(see edit below) sudo apt-get update sudo apt-get install python3.6-tk (you may have to install a different python*-tk depnding on the python version you’re using) pip install … Read more

Get err_connection_refused accessing django running on wsl2 from Windows but can curl from Windows terminal

Seems like a forwarding problem. WSL2’s interface is NAT’d, whereas WSL1 was bridged by default. WSL seems to do some “auto-forwarding” of ports, but only on localhost. However, sometimes this auto-forwarding mechanism seems to “break down”. The main culprit seems to be hibernation or Windows Fast Startup (which are both closely-related features). Does the problem … Read more

What is the difference between calling a command via “wsl [command]” and opening a wsl shell and calling “[command]”?

To be honest, when I first looked at this question, I thought it would be an easy answer. Oh how wrong I was. There are a lot of nuances to how this works. Let’s start with the fairly “easy” part, though. The main difference between the first method and the second: wsl by itself launches … Read more

Connecting to WSL2 server via local network

See this video, it helped me: https://www.youtube.com/watch?v=yCK3easuYm4 netsh interface portproxy add v4tov4 listenport=<port-to-listen> listenaddress=0.0.0.0 connectport=<port-to-forward> connectaddress=<forward-to-this-IP-address> for example netsh interface portproxy add v4tov4 listenport=3000 listenaddress=0.0.0.0 connectport=3000 connectaddress=172.30.16.3 Microsoft has published a little bit of information about this on their WSL1 to WSL2 comparison page

How do I use Bash on Ubuntu on Windows (WSL) for my VS Code terminal?

This answer seeks to help others avoid spending 1-2 hours troubleshooting and slowly finding disparate solutions for common problems when using WSL for the terminal in VS Code. It does not cover installing specific packages, but rather common ones that may not properly install as dependencies when installing things that do rely on their presence, … Read more

How can nodemon be made to work with WSL 2?

Root cause: inotify is not fully supported in the 9P filesystem protocol on WSL2. There are several github issues on the WSL project related to this, but perhaps the most relevant is #4739. Possible Workarounds: Try nodemon -L (a.k.a. –legacy-watch) as Simperfy suggested. Try running from the default ext4 filesystem (e.g. mkdir -p $HOME/Projects/testserver). Note … Read more