Start with WSL2’s localhost forwarding, then open http://localhost:PORT from Windows. Keep the server bound to 127.0.0.1 unless a specific tool needs a different bind address, and check WSL networking mode if Windows cannot reach the port. That keeps the browser, editor, and shell on Windows while the server runs inside Linux.
What WSL2 changes
WSL2 runs Linux inside Windows with its own kernel, so Ubuntu and other distributions can run Linux-native web stacks without dual boot. Windows desktop apps and browsers can still talk to those tools. For local development, that usually means one shell on Windows, one server in Linux, and one browser tab on Windows.
What Ubuntu on WSL adds
Ubuntu is a common default for WSL2 because local dev guides and packages often target it first. It also gives you a separate Linux username and password, which keeps Linux file ownership and service behavior predictable. Windows can still reach those files through \\wsl$ in File Explorer.
What you'll need
- Windows 10 version 2004 build 19041 or newer, or a current Windows 11 install.
- Windows Terminal or PowerShell for install and status checks.
- An installed WSL distribution such as Ubuntu.
- A project folder inside the Linux filesystem, ideally
/home/<user>/projects. - Visual Studio Code with Remote WSL.
- A browser on Windows for localhost access.
- A Docker-compatible local stack if your app needs one, such as Supabase local development.
Should you keep code in /home or on /mnt/c?
Keep project files in /home/<user>/projects for most WSL2 web stacks. That path stays inside the Linux filesystem, which avoids the file translation overhead and permission mismatch that appear when code lives on /mnt/c. For typical development, /mnt/c is the wrong default.
When /mnt/c is the weaker choice
Windows-mounted files can slow down package installs, dependency scans, and file watchers because Linux tools cross a filesystem boundary on every read and write. Permissions can also behave differently, especially when a tool expects Linux ownership and execute bits. If a stack is sensitive to file churn, move it into /home.
Suppose a Node app starts fast from /home/alex/projects/site but drags when copied to /mnt/c/Users/alex/Desktop/site. That difference usually comes from the storage path, not the app code. Move the project back into Linux storage before chasing tooling changes.
How do you install and start WSL2?
Use Windows Terminal or PowerShell to install WSL2, then launch the chosen distro and create its Linux user account. The quickest path is wsl --install, followed by a restart if Windows asks for one. After that, verify the distro list and the WSL version before opening the project.
- Install WSL2. Run
wsl --installin Windows Terminal or PowerShell. On Windows 10, the system must be version 2004 build 19041 or newer. - Start Ubuntu. Launch the distro from the Start menu or by typing
wslin PowerShell. The first run creates the Linux username and password. - Verify the install. Run
wsl --list --verboseto confirm the distro and its WSL version. If needed, set WSL2 for that distro from Windows settings or the command line. - Create a project folder. In the Linux shell, run
mkdir -p ~/projects. Put new work there unless a tool has a specific reason to live elsewhere.
How do you start WSL2 from Windows Terminal or PowerShell?
Open Windows Terminal or PowerShell and run wsl to enter the default Linux distribution. Use wsl -d Ubuntu if you want a specific distro. That keeps Windows as the entry point while the shell, package manager, and server process run in Linux.
How do you open the project in VS Code?
Open the code from inside WSL so terminals, extensions, and build tools run in Linux while the editor UI stays on Windows. The shortest path is the VS Code Remote WSL flow from the Linux shell. Windows File Explorer can also reach the same files through \\wsl$.
Open from the Linux shell
- Change into the project. In WSL, run
cd ~/projects/your-app. Keep the path under/homefor best results. - Launch VS Code. Run
code .from that directory. VS Code opens the folder in Remote WSL mode, so the toolchain stays inside Linux. - Confirm the terminal. Open a new terminal in VS Code and check that it starts in the WSL shell, not PowerShell. That avoids mixed package managers and path confusion.
Open from Windows Explorer
Type \\wsl$ in File Explorer’s address bar, then browse to the distro and project folder. This is useful for copying files, inspecting logs, or opening the same project from the Windows side without moving it out of Linux storage.
Can you run a local dev stack inside WSL2 and keep it private?
Yes. A local stack can run inside WSL2 and stay private if it binds to localhost and you avoid public exposure. For container-based stacks, use a Docker-compatible runtime and keep published ports limited to the local machine. Supabase local development requires a container runtime compatible with Docker APIs, and its local stack is normally viewed at http://localhost:54323.
Start the server inside Linux
- Start the app or stack. Run your server from the WSL shell, such as the app’s dev command, Nginx, Apache, or a container stack.
- Check the port binding. Confirm the service listens on the expected port with a command such as
ss -ltnpinside WSL. Use the port your app prints, then browse tohttp://localhost:PORTfrom Windows. - Keep exposure local. Bind the service to
127.0.0.1when the tool supports it. That keeps the stack on the machine and avoids unnecessary network exposure.
When Docker-compatible stacks matter
Some local workflows need containers, not just a process runner. Supabase local development is one example, and it expects a Docker-compatible runtime. If the stack is only for local use, keep it bound to localhost and avoid publishing it beyond the machine. Never expose a local development stack publicly.
Picture a Supabase stack running in WSL2 with its dashboard at http://localhost:54323. If Windows can open that address, the browser path is fine and the problem is elsewhere. If the page fails only after a reboot, the likely issue is service startup, not the browser.
What about systemd?
Use systemd in WSL when the stack depends on Linux services, user units, or rootless tooling. Newer WSL versions support it, which helps with background services that need normal Linux service management instead of a hand-run shell process. If a tool expects a daemon, systemd is often the cleanest route.
Server troubleshooting matrix
| Symptom | Likely cause | Exact check command | Fix |
|---|---|---|---|
http://localhost:PORT fails in Windows |
The server is not running, the port is wrong, or WSL localhost forwarding is not in the path | wsl --list --verbose then ss -ltnp inside WSL |
Start the service, confirm the port, then retry the same localhost URL from Windows |
| File watcher or install step is slow | The project is on /mnt/c |
pwd |
Move the repo to /home/<user>/projects and reopen it there |
| Permission denied on a script or dependency | Windows storage permissions do not match Linux expectations | ls -l |
Move the project into Linux storage, then fix ownership or execute bits with standard Linux commands |
| Windows cannot reach a WSL service by port | Networking mode, port conflict, or port publishing is blocking access | ss -ltnp and cat /etc/wsl.conf |
Check for mirrored or bridged behavior, stop the conflicting process, and verify the service still binds to the expected port |
| Service works after launch, then disappears later | The process exits when the shell closes or systemd is not enabled | ps -ef | grep -i your-service |
Enable systemd where needed, then run the service as a unit so it survives shell closure |
Say the browser opens the app once, then the next reboot leaves the port dead. That usually means the service started manually in a shell and never became a background service. Move it under systemd or a container launch path before changing the code.
Common mistakes
- Keeping code on
/mnt/cand blaming the framework for slow file access. - Opening the project from Windows first, then wondering why the terminal uses the wrong toolchain.
- Confusing the Windows browser path with the Linux shell path.
- Publishing a local container beyond localhost when only the local machine needs it.
- Skipping
wsl --list --verboseand assuming the distro is already on WSL2.
For Docker-based stacks, check the container runtime first, then the port, then the browser. For process-based stacks, check the shell session first, then systemd, then localhost access. That order avoids chasing network settings before the service exists.
Frequently asked questions
How do I install WSL2 on Windows for development?
Open Windows Terminal or PowerShell and run wsl --install. After installation, run wsl --list --verbose to verify the distro and the WSL version before you start a project.
Should I keep project files in /home or on /mnt/c in WSL2?
Use /home/<user>/projects for normal WSL development. That keeps file access inside Linux and avoids the performance and permission issues that show up on /mnt/c. Move the repo back to Linux storage before troubleshooting anything else.
How do I access WSL files from Windows File Explorer?
Open File Explorer and enter \\wsl$ in the address bar. Browse to the distro, then open the project folder directly. That path lets Windows tools view Linux files without copying them out of WSL.
How do I open a WSL2 project in VS Code Remote WSL?
From the WSL shell, go to the project folder and run code .. VS Code opens the folder in Remote WSL mode, so terminals and extensions run in Linux while the editor window stays on Windows.
How do I expose a service running in WSL2 to Windows browsers?
Start the server in WSL, confirm the listening port with ss -ltnp, then open http://localhost:PORT in a Windows browser. Current WSL2 often forwards localhost, but networking mode and port conflicts can still change the result.
How do I avoid firewall and port-forwarding problems with WSL2?
Keep the service bound to localhost when possible, verify that the right process owns the port, and avoid public exposure. If Windows still cannot connect, check WSL networking mode and any port conflict before changing firewall settings. For SSH-based workflows, Windows OpenSSH can enter WSL without extra port forwarding.