Logo - Man staring upon the night sky full of stars

How to setup WSL on Windows 11

2024-12-22

Install WSL

This should install the latest version.

wsl --install --web-download

If you get stuck downloading Ubuntu during the installation you can cancel the process and just install it like this

wsl --install Ubuntu --web-download

This will list all the installed WSL distros.

wsl --list

Update WSL

In case you need to update later on.

wsl --update --web-download

Access WSL from Terminal

Write wsl in terminal to access WSL.

Or if you using the Windows Terminal you can create a new tab by clicking the arrow next to the + button and select Ubuntu.

You should have at least version 2 of WSL installed.

wsl
wslinfo --wsl-version
#2.3.26

Share network between WSL and Windows

This will mirror the network so if you have a windows process running on localhost:5173 it will be accessible on WSL as 127.0.0.1:1234.

And vice versa if you run for example Vite on WSL you can access it from your Windows browser at localhost:5173.

Create file .wslconfig in C:\Users\<username>\

[wsl2]
networkingMode=mirrored

Shutdown WSL after you made this file.

wsl --shutdown

Then in WSL check if the networking mode is now mirrored.

wsl
wslinfo --networking-mode
# should say mirrored

Link Windows folder to WSL

Link the existing Windows folder to the WSL linux folder. You need to run this from withing WSL

ln -s /mnt/c/path/to/windows/folder ~/desired/ubuntu/location

This technically allows you to edit files in the linked Windows folder without connecting to WSL. But listening for file changes won't work. So for example Vite hot reloading won't work and you'd have to reload manually.

Node setup

Follow this Stack Overflow answer to install Node.js and npm

VS Code setup

Follow this official VS Code guide

Hibernation ❗

Be warned that hibernating you computer without shutting down WSL might break it. Either it might become unresponsive or the mirrored networking will break.

So be carefule to always shutdown WSL before hibernating.

wsl --shutdown

Sometimes you might need to run this as admin.