WSL 2 Networking Not Working — No Internet Access from Linux Subsystem
About WSL 2 Networking Not Working
Fix WSL 2 networking issues where Linux distributions have no internet access, DNS resolution fails, or cannot reach external hosts from inside WSL. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.
Here are the key things to understand: WSL 2 uses a virtual network adapter with NAT to provide network connectivity to Linux distributions. DNS resolution inside WSL defaults to the host Windows DNS settings via auto-generated /etc/resolv.conf. VPN software on Windows can break WSL 2 networking by changing routing tables. Firewall rules on the Windows host can block WSL 2 network traffic. WSL 2 runs in a lightweight VM with its own network stack separate from Windows. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.
The most common reasons this occurs include: VPN software (Cisco AnyConnect, GlobalProtect) changing routing tables and breaking WSL NAT. DNS resolution failing because /etc/resolv.conf points to an unreachable DNS server. Windows Firewall or third-party firewall blocking WSL 2 virtual adapter traffic. Hyper-V virtual switch misconfigured after a Windows update. Identifying the root cause is the first step toward finding the right solution.
To resolve this, follow these recommended steps: Test connectivity: run "ping 8.8.8.8" in WSL — if this works but DNS fails, it is a DNS issue. Fix DNS manually: edit /etc/resolv.conf and set nameserver to 8.8.8.8 or 1.1.1.1. Prevent auto-generation: create /etc/wsl.conf with [network] generateResolvConf=false. For VPN issues: add WSL routing rules — wsl.exe requires special routes when VPN is active. Restart WSL: run "wsl --shutdown" in PowerShell then relaunch your Linux distribution. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.
This article is part of our Windows Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.
Quick Answer
Why does WSL lose networking when I connect VPN?
VPN clients modify Windows routing tables. WSL 2 NAT traffic may be routed through the VPN tunnel which blocks or reroutes it. Some VPNs explicitly block local VM traffic. Configure VPN split tunneling to exclude WSL traffic.
Overview
Fix WSL 2 networking issues where Linux distributions have no internet access, DNS resolution fails, or cannot reach external hosts from inside WSL.
Key Details
- WSL 2 uses a virtual network adapter with NAT to provide network connectivity to Linux distributions
- DNS resolution inside WSL defaults to the host Windows DNS settings via auto-generated /etc/resolv.conf
- VPN software on Windows can break WSL 2 networking by changing routing tables
- Firewall rules on the Windows host can block WSL 2 network traffic
- WSL 2 runs in a lightweight VM with its own network stack separate from Windows
Common Causes
- VPN software (Cisco AnyConnect, GlobalProtect) changing routing tables and breaking WSL NAT
- DNS resolution failing because /etc/resolv.conf points to an unreachable DNS server
- Windows Firewall or third-party firewall blocking WSL 2 virtual adapter traffic
- Hyper-V virtual switch misconfigured after a Windows update
Steps
- 1Test connectivity: run "ping 8.8.8.8" in WSL — if this works but DNS fails, it is a DNS issue
- 2Fix DNS manually: edit /etc/resolv.conf and set nameserver to 8.8.8.8 or 1.1.1.1
- 3Prevent auto-generation: create /etc/wsl.conf with [network] generateResolvConf=false
- 4For VPN issues: add WSL routing rules — wsl.exe requires special routes when VPN is active
- 5Restart WSL: run "wsl --shutdown" in PowerShell then relaunch your Linux distribution