What WSL is and why you'd run it as a server

Windows Subsystem for Linux (WSL) lets you run a Linux environment directly on Windows without a virtual machine. When you enable it, you get a real Linux kernel running alongside Windows, with access to Linux command-line tools, package managers, and development environments. You can then configure services — like a web server, database, or application — to run continuously in the background, treating your Windows machine as a Linux server would work.

This is useful if you develop on Linux but use Windows as your main machine, or if you want to test server software locally before deploying it elsewhere. WSL runs the actual Linux kernel (as of WSL 2), not an emulation, so performance is close to native Linux.

Key Takeaways

  • WSL requires Windows 10 version 2004 or later, or Windows 11; you turn it on through Windows Features, then install a Linux distribution from the Microsoft Store.
  • WSL 2 (the current version) uses a real Linux kernel and is faster for most server tasks than WSL 1, though it uses more memory.
  • Services you run in WSL are accessible from Windows via localhost and from other machines on your network via your Windows machine's IP address.
  • WSL does not start automatically when Windows boots; you must either start it manually or configure it to launch services on startup using systemd or a scheduled task.

Check your Windows version and enable WSL

WSL 2 requires Windows 10 version 2004 or later, or any version of Windows 11. To check your version, press Windows key + R, type winver, and press Enter. Look at the "Version" field; if it shows 2004 or higher, you can proceed.

To turn on WSL, open PowerShell as Administrator (right-click the PowerShell icon and select "Run as administrator") and type:

wsl --install

This command enables WSL, installs WSL 2, and downloads Ubuntu as the default Linux distribution. If you want a different distribution — Debian, Fedora, or another — you can specify it: wsl --install -d Debian. After the installation finishes, restart your computer.

If you already have WSL 1 installed and want to upgrade to WSL 2, run wsl --set-default-version 2 in PowerShell. This makes any new distributions use WSL 2 by default.

Launch WSL and set up your Linux environment

After restart, open the Microsoft Store, search for your chosen distribution (Ubuntu, Debian, Fedora), and click "Install" if you did not use the automated install. Once installed, click "Launch" or search for the distribution name in your Start menu and open it.

The first time you launch, Linux will ask you to create a username and password. These are your Linux user credentials, separate from your Windows login. Write them down — you will need the password for commands that require elevated permissions (like installing packages).

Once you are at the Linux prompt, update your package manager. For Ubuntu or Debian, type:

sudo apt update && sudo apt upgrade

For Fedora, type sudo dnf upgrade. This ensures your distribution has the latest security patches and software versions.

Install and configure a server application

What you install depends on what you want to run. Common choices are Nginx or Apache for a web server, PostgreSQL or MySQL for a database, or Node.js for a JavaScript application server. Here is an example with Nginx:

sudo apt install nginx

After installation, start the service:

sudo systemctl start nginx

Check that it is running:

sudo systemctl status nginx

You should see "active (running)" in the output. To make Nginx start automatically whenever you launch WSL, enable it:

sudo systemctl enable nginx

Test that the server is reachable by opening a web browser on your Windows machine and going to http://localhost. You should see the Nginx welcome page. If you are accessing from another machine on your network, use your Windows machine's IP address instead of localhost — find it by typing ipconfig in a Windows command prompt and looking for "IPv4 Address" under your active network adapter.

Make WSL services start when Windows boots

By default, WSL does not launch automatically when you start Windows, so your server will not be running until you manually open the WSL terminal. To change this, you have two main options.

The first option is to use systemd, which is the standard Linux service manager. In recent versions of WSL 2, systemd is enabled by default. If your distribution supports it, services you enable with systemctl enable will start automatically the next time you launch WSL. However, this still requires you to open the WSL terminal at least once.

The second option is to use a Windows Task Scheduler entry to launch WSL and your service on boot. Open Task Scheduler (search for it in the Start menu), click "Create Basic Task", give it a name like "Start WSL Server", and set the trigger to "At startup". For the action, set the program to C:\Windows\System32\wsl.exe and the arguments to -d Ubuntu -u root -e /usr/sbin/service nginx start (replace Ubuntu with your distribution name and nginx with your service). This approach starts the service without requiring you to open a terminal.

Access your server from Windows and other machines

Services running in WSL are accessible from your Windows machine using localhost or 127.0.0.1 plus the port number. If Nginx is running on port 80, you reach it at http://localhost or http://localhost:80.

To access your WSL server from another machine on your network, use your Windows machine's IP address. Open Command Prompt on Windows and type ipconfig. Find the line labeled "IPv4 Address" under your active network connection — it usually looks like 192.168.x.x or 10.x.x.x. From another machine, visit http://192.168.x.x (using your actual IP) to reach your server.

If you cannot reach the server from another machine, check your Windows Firewall. Open "Windows Defender Firewall" in Settings, click "Allow an app through firewall", and make sure your server application (or WSL) is listed and checked for both Private and Public networks. You may need to add it manually if it is not there.

Troubleshoot common issues

If WSL installation fails, make sure virtualization is enabled in your BIOS. Restart your computer, enter the BIOS (usually by pressing Delete, F2, or F12 during startup — check your computer's manual), and look for a setting called "Virtualization", "VT-x", or "SVM". Enable it and save.

If your server starts but you cannot reach it from Windows, check that it is actually listening on the correct port. In WSL, type sudo netstat -tlnp or sudo ss -tlnp to see what ports are in use. Look for your service in the list. If it is not there, the service may have failed to start — check its logs with sudo journalctl -u nginx (replace nginx with your service name).

If you want to stop a service, type sudo systemctl stop nginx. To disable it from starting automatically, type sudo systemctl disable nginx. To restart it, type sudo systemctl restart nginx.

Frequently Asked Questions

Can I run multiple servers at the same time in WSL?

Yes. You can install and run as many services as your hardware supports. Each service listens on a different port — for example, Nginx on port 80, PostgreSQL on port 5432, and Node.js on port 3000. From Windows, you reach them all via localhost with the appropriate port number.

Does WSL 2 use a lot of memory?

WSL 2 uses more memory than WSL 1 because it runs a real Linux kernel, but it is much faster for most tasks. A basic server typically uses 200 MB to 500 MB. If memory is tight, you can limit WSL's memory usage by creating a file at C:\Users\[YourUsername]\.wslconfig with the line memory=2GB (adjust the number to your needs).

What happens to my WSL server if I put my computer to sleep?

The server keeps running. WSL continues to run in the background even when your Windows machine is in sleep mode, as long as you have not closed the WSL terminal. If you shut down Windows completely, the server stops until you restart and launch WSL again.

Can I access files in WSL from Windows?

Yes. In File Explorer, type \\wsl$ in the address bar to see your WSL distributions and browse their files. You can also access Windows files from WSL at /mnt/c (for the C: drive), /mnt/d (for D:), and so on.

Is WSL suitable for production servers?

No. WSL is designed for development and testing on a local machine. For production, use a dedicated Linux server, a cloud provider like AWS or DigitalOcean, or a container platform like Docker. WSL will shut down if you restart Windows, and it is not designed to handle the reliability and uptime requirements of production systems.