wsl --set-version to 1 switches to a legacy integration model where the Linux kernel runs directly on the Windows networking stack, granting immediate access to local resources without complex port forwarding rules.
Understanding the Networking Difference Between WSL Versions
The primary distinction between WSL1 and WSL2 lies in how they handle network interfaces. WSL2 operates as a lightweight utility VM with its own virtual hard disk and network adapter. It sits behind a Network Address Translation (NAT) gateway, which means it has a dynamic IP address that changes every time the instance restarts. This isolation provides security but complicates scenarios where you need the Linux distribution to appear as a specific device on your local network or access shared drives via standard SMB paths without additional configuration.
In contrast, WSL1 does not run a full virtual machine. Instead, it translates Linux system calls into Windows NT kernel calls in real-time. From a networking perspective, this means the Linux processes are essentially running on top of the Windows TCP/IP stack. They inherit the host's IP address and network identity, making connectivity trivial for basic tasks like accessing localhost services or using shared folders.
How to Set WSL Version to 1
If your workflow requires the simplicity of WSL1 networking, you can convert an existing WSL2 distribution to WSL1. Ensure that no critical data is lost during conversion, although the process generally preserves files in the virtual disk. Open PowerShell or Command Prompt as an Administrator and execute the following command:
wsl --set-version <DistroName> 1
Replace <DistroName> with the actual name of your distribution, such as Ubuntu-20.04. You can list available distributions by running wsl -l. The conversion process may take several minutes depending on the size of the virtual disk. Once completed, verify the change by checking the status again.
After switching, your distribution will immediately gain access to the host's network interface. Services running on Windows, such as IIS or SQL Server Express, become accessible directly from within the Linux shell using localhost or the host's static IP address. This method bypasses the need for manual port forwarding configurations often required in WSL2.
When to Use WSL1 Networking Over WSL2
While WSL2 is the recommended default for most development tasks due to superior performance and compatibility with Docker, there are specific use cases where WSL1 networking is preferable. If you are building simple scripts that rely heavily on direct file system access to Windows drives without experiencing the slow I/O speeds sometimes associated with cross-platform file operations in WSL2, WSL1 offers faster read/write times for mixed workloads.
Additionally, developers working on legacy applications that depend on specific network behaviors found in older Linux kernels might find WSL1 more predictable. For example, if you are testing network tools that assume a flat network topology without NAT complications, WSL1 provides a transparent view of the network. However, keep in mind that WSL1 lacks support for systemd, which limits the ability to run complex background services that require traditional init systems.
Troubleshooting Connectivity Issues
Even after setting the version to 1, you might encounter connectivity issues if your Windows firewall blocks incoming connections. Since WSL1 shares the host's network identity, any service listening on a port must be allowed through the Windows Defender Firewall. Check your inbound rules to ensure that the application you are trying to reach from WSL is permitted.
If you experience DNS resolution failures, verify that your Windows DNS settings are correctly configured. WSL1 inherits these settings directly, so misconfigurations at the host level will propagate to the Linux environment. Restarting the WSL instance using wsl --shutdown followed by launching the distribution again can often resolve stale network state issues.
For more advanced networking needs in WSL2, consider exploring Configuring Port Forwarding with WSL2 and IP Passthrough, which allows you to maintain the performance benefits of WSL2 while achieving similar network accessibility.
Risks of Downgrading to WSL1
Downgrading to WSL1 comes with significant trade-offs. You lose the ability to run Docker containers natively, as Docker Desktop relies on the Hyper-V or WSL2 backend. Furthermore, certain Linux utilities and kernel modules that are not supported in the translation layer of WSL1 will fail to execute. If your project depends on these features, sticking with WSL2 and configuring proper port forwarding is the better long-term solution.
Frequently Asked Questions
Can I switch back to WSL2 later?
Yes, you can revert to WSL2 at any time using the same command structure: wsl --set-version <DistroName> 2. The conversion process is reversible, and your files remain intact during the transition. However, you should be aware that switching back may require reconfiguring network settings if you relied on WSL1's direct host access.
Does WSL1 support systemd?
No, WSL1 does not support systemd. It uses a simpler initialization mechanism that starts services defined in /etc/wsl.conf or launched manually. If your workflow depends on managing complex background services with systemd, you must continue using WSL2 or utilize alternative process managers like supervisord.
Why is my internet slower in WSL2 than WSL1?
WSL2 involves an extra layer of virtualization and NAT translation, which can introduce slight latency compared to WSL1's direct integration with the Windows network stack. While WSL2 offers better CPU performance, network throughput for small packets may feel less responsive in WSL1 due to the overhead of context switching in the virtual machine.
How do I check the current WSL version?
You can check the version of all installed distributions by running wsl -l -v in PowerShell or Command Prompt. This command lists each distribution along with its corresponding version number, allowing you to verify whether you are currently using WSL1 or WSL2.
Is WSL1 still supported by Microsoft?
Microsoft continues to support WSL1, but it is considered a legacy mode. Future updates and new features are primarily targeted at WSL2. While WSL1 remains functional for basic tasks, it is not recommended for new projects requiring modern Linux kernel features or containerization support.