WSL2 No Internet or DNS Not Resolving? How to Fix resolv.conf and VPN Issues

Short answer
WSL2 no internet: why does it happen, and what should you check first?
A WSL2 no internet problem means the Linux virtual machine cannot reach the network through Windows, or cannot turn domain names into IP addresses. The most common cause is an unreachable DNS server in /etc/resolv.conf. VPN clients, firewalls and NAT routing trigger it. First, ping an IP address to separate DNS failures from connectivity failures.
Your browser on Windows works fine, but inside Ubuntu on WSL2 apt update hangs and ping google.com fails with a "Temporary failure in name resolution" style message. In that case the internet itself is rarely the problem. The break almost always sits in the WSL2 networking or DNS layer. This guide helps you sort a WSL2 no internet problem in a few minutes, then fix it with the right tool: resolv.conf, wsl.conf, .wslconfig, mirrored networking, or VPN specific settings.
Work through this order before you edit any file. That way you avoid stacking fixes on top of each other:
- Inside WSL, run
ping -c 3 1.1.1.1. If replies come back, you have connectivity and the issue is DNS. - Next, run
ping -c 3 google.com. If the IP works and the name fails, name resolution is broken. - If the IP ping also fails, look at routing, the firewall or your VPN.
- In PowerShell, run
wsl --shutdownand reopen your distro. Sometimes this step alone clears the problem.
This article covers network and DNS failures only. If you want the basics of the platform first, read our guide on what WSL2 is and how to use it as a Linux dev environment on Windows.
How does WSL2 networking work, and where does it break?
According to Microsoft's official WSL networking documentation, WSL uses a NAT based architecture by default. In other words, your Linux distro has its own virtual network adapter and its own IP address. Windows acts like a router for that virtual machine. So every packet that leaves Linux travels through Windows first, then out through the physical adapter.
DNS follows a similar bridge. When the distro starts, WSL writes /etc/resolv.conf itself and points it at a name server on the Windows side. Linux sends every lookup there. Therefore, if any link in that bridge fails, Linux reports a resolution error even though Windows can browse the web.
Typical breaking points look like this:
- A VPN client rewrites the routing table and the NAT traffic no longer reaches the tunnel.
- A corporate firewall blocks DNS packets that come from the virtual machine.
- Someone edited resolv.conf by hand, and it now points at a dead server.
- Someone disabled IPv6 in the Windows registry, and WSL connectivity broke with it.
Is it really WSL2 no internet, or just DNS not resolving?
In practice, this distinction is half of the fix. Many searches that start with "no internet" turn out to involve working connectivity and broken name resolution. The diagnostic table below maps what you see to the likely cause and the first check.
| Symptom | Likely cause | First check |
|---|---|---|
| IP ping works, domain ping fails | The DNS server in resolv.conf is unreachable | cat /etc/resolv.conf and the nameserver line |
| Everything stops when the VPN connects | VPN routing conflicts with NAT, or VPN DNS policies skip Linux | Disconnect the VPN and test again |
| Fails only on the work laptop | Firewall local rule merging is off | Ask IT about a Hyper-V firewall rule |
| IP ping fails too | Routing, firewall or networking mode issue | Default gateway in ip route |
| resolv.conf resets on every start | generateResolvConf is still on | The [network] section in /etc/wsl.conf |
| Container cannot resolve, WSL shell can | Docker Desktop uses its own DNS path | Container network settings |
Each row has its own section below. Find your symptom and jump straight to it.
What is resolv.conf, and why does it break?
/etc/resolv.conf tells Linux which server to ask when it needs to resolve a domain name. It contains one or more nameserver lines. WSL creates the file automatically. The official WSL configuration reference ties that behavior to the generateResolvConf key in wsl.conf and lists true as the default.
The file usually breaks in one of three ways. First, you follow a forum tip and edit the file, but you never turn off auto generation, so WSL overwrites your change at the next start. Second, you turn off auto generation, but the file keeps a server that no longer exists. Third, the file is a symbolic link, and its target disappeared.
To see what you have, run ls -l /etc/resolv.conf and cat /etc/resolv.conf together. For example, a comment at the top saying WSL generated the file means auto generation is on. An arrow in the ls output tells you the file is a link.
The official troubleshooting page also notes a limit: resolv.conf holds a maximum of three DNS servers, while Windows may use more. That gap alone can make resolution inconsistent on some networks.
How do you fix resolv.conf manually and make it stick?
A permanent manual fix touches two files. First you stop WSL from generating resolv.conf, then you write the file yourself. Follow these steps in order:
- Inside WSL, open the file with
sudo nano /etc/wsl.confand addgenerateResolvConf=falseunder a[network]heading. - In PowerShell, run
wsl --shutdownand let WSL stop completely. - Reopen WSL and remove the old link with
sudo rm /etc/resolv.conf. - Create a new /etc/resolv.conf and add the
nameserverline you want. - Confirm the result with
ping -c 3 google.com.
Which server you choose depends on your network. On a home network, a public resolver usually works. On a corporate network, however, only the company DNS server can resolve internal hostnames. So a public resolver on a work laptop might restore internet access and break internal tools at the same time.
One more caution. According to the official documentation, DNS tunneling, which we cover below, does not enable properly when generateResolvConf is off. You pick one approach; you cannot run both.
What is the difference between wsl.conf and .wslconfig?
The two names look almost identical, so people often write a setting into the wrong file. Per the official reference, wsl.conf holds per distro settings and lives inside Linux at /etc/wsl.conf. In contrast, .wslconfig holds global settings for every WSL 2 distro and lives in your Windows user profile folder.
| Aspect | /etc/wsl.conf | %UserProfile%\.wslconfig |
|---|---|---|
| Scope | One distro | All WSL 2 distros |
| Typical network keys | generateResolvConf, generateHosts, hostname | networkingMode, dnsTunneling, firewall, autoProxy, dnsProxy |
| Section label | [network] | [wsl2] |
| Where you edit it | From Linux with sudo | From Windows, or the WSL Settings app |
In short, resolv.conf generation belongs to the distro, while the networking mode belongs to WSL as a whole. Also, the official reference recommends the WSL Settings app in the Start menu over hand editing .wslconfig. According to the same page, WSL still launches if the file is malformed; it simply skips your settings, which makes typos hard to spot.
Does your WSL version affect networking problems?
Yes, it can. Mirrored mode, DNS tunneling, autoProxy and the Hyper-V firewall all depend on specific Windows and WSL versions, according to Microsoft's documentation. On an older install, you can add those keys to .wslconfig and see no effect at all.
So before you diagnose anything, run wsl --version in PowerShell. The official configuration page says that if this command is not recognized, you probably run an older inbox version of WSL that needs an update. You can get the current release from the Microsoft Store.
Also check whether your distro runs as WSL 1 or WSL 2 with wsl --list --verbose. .wslconfig settings apply to WSL 2 distros only. For instance, if you installed a distro long ago under WSL 1 and never converted it, none of the networking modes in this guide touch it.
A version check takes thirty seconds and saves hours in the wrong direction. Write the number down, because it is the first thing IT or a forum will ask for.
Why don't configuration changes take effect right away?
Many people make the right change, close the terminal, reopen it and see nothing different. The reason is simple, because closing the window does not stop the virtual machine. Microsoft's configuration page calls this the "8 second rule"; after you close every shell, the subsystem typically needs about that long to stop.
Instead of waiting, use wsl --shutdown. Keep in mind that it stops every running distro, so save any open database session or build first. To restart a single distro, use wsl --terminate with the distro name.
To confirm it stopped, run wsl --list --running in PowerShell. Once no distro runs, WSL reads your new settings at the next launch. In practice, make it a habit after every config change: save, shut down, verify.
WSL2 no internet when the VPN connects: what should you do?
VPN related outages are the most common scenario. Microsoft's WSL troubleshooting page describes two routes: point DNS manually at the VPN server through resolv.conf, or rely on DNS tunneling.
For the manual route, connect the VPN and run ipconfig.exe /all on Windows to note the DNS server of the VPN adapter. Then turn off generateResolvConf as described above and put that server on the first line of resolv.conf. However, the official page also says you must revert that change after you disconnect. Otherwise resolution fails on your home network.
As a result, the manual route gets tedious if you connect only now and then. If you connect often, making sure DNS tunneling is on is the more sustainable choice. The official page specifically recommends tunneling for VPN users, because many VPNs apply name resolution rules through NRPT policies on Windows, and those policies reach Linux queries only when tunneling is on.
Choosing a VPN is a separate topic. For the risks of free services, see our article on whether free VPNs are safe.
What is DNS tunneling (dnsTunneling), and how do you turn it on?
DNS tunneling lets Linux hand its DNS queries to Windows through a virtualization feature instead of sending them as network packets. The official troubleshooting page explains that WSL sometimes cannot reach the internet because the host network configuration blocks the DNS packet from the virtual machine to Windows. Tunneling removes that packet, so the block no longer applies.
According to the documentation, the feature is on by default on Windows 11 22H2 and later, and you control it with the dnsTunneling key under [wsl2] in .wslconfig. To see whether someone turned it off, look for that key set to false.
Tunneling comes with side effects worth knowing:
- If generateResolvConf is off, tunneling does not enable properly.
- With tunneling on, WSL does not copy the Windows hosts file into Linux, but its rules still apply to Linux queries.
- If Windows uses encrypted DNS, WSL encrypts Linux queries too. To run encrypted DNS inside Linux yourself, you need to turn tunneling off.
- Containers that Docker Desktop manages bypass tunneling for their DNS queries.
With tunneling on, the nameserver in resolv.conf comes from an address listed under the experimental settings. Do not memorize that value; check the current value on the official configuration page.
What is networkingMode mirrored, and does it fix WSL2 no internet?
Mirrored networking is a newer architecture that mirrors your Windows network interfaces into Linux. The official networking page says you enable it on Windows 11 22H2 and later by adding networkingMode=mirrored under [wsl2] in .wslconfig. The listed benefits include IPv6 support, reaching Windows servers through localhost, and improved compatibility with VPNs.
In other words, mirrored mode removes some problems that the NAT bridge creates. That makes it worth a try if your VPN keeps cutting WSL off. Then follow these short steps:
- Open or create .wslconfig in your Windows user folder.
- Add
networkingMode=mirroredunder a[wsl2]heading. - Run
wsl --shutdownand reopen WSL. - Repeat the IP and domain ping tests.
That said, mirrored mode is no magic switch. The official troubleshooting page states that Microsoft tested some VPN products and confirmed them as incompatible with WSL in this mode. Also, on Windows 10 this option does not exist for you; the reference lists the setting for Windows 11 only.
WSL2 no internet on a work laptop: is the firewall to blame?
Corporate devices show a familiar pattern: the same WSL setup works at home and fails completely on the work laptop. The official troubleshooting page explains that companies may configure Windows Defender Firewall to block unauthorized traffic. If local rule merging is off, WSL networking does not work by default, and an administrator needs to add a firewall rule.
Still, do not try to work around security policy on your own. Changing rules on a managed device likely exceeds your permissions and may break company policy. Instead, give your IT team clear facts: you use WSL2, you tested IP versus domain reachability, and the Hyper-V firewall settings need to allow WSL traffic.
The networking page also notes that on Windows 11 22H2 and later, with recent WSL releases, the Hyper-V firewall is on by default. The firewall key in .wslconfig decides whether Windows firewall rules filter WSL traffic. On a managed device, asking IT for a proper rule beats switching that key off.
Why did WSL2 lose connectivity after you disabled IPv6?
Some users disable IPv6 in the Windows registry hoping for a faster connection. Microsoft's troubleshooting page states plainly that disabling IPv6 through the DisabledComponents registry value can break WSL network connectivity.
The documented alternative: if you truly must disable IPv6, use PowerShell to remove the IPv6 protocol binding from the specific network adapter instead of editing the registry. That way the internal plumbing WSL depends on stays in place.
If you wonder how your connection looks from the outside, our what is my IP tool shows the public address Windows uses. Don't confuse it with the address inside WSL; in NAT mode, WSL2 uses its own internal IP.
Why can't WSL2 get out on networks that use a proxy?
Some corporate networks allow internet access only through an HTTP proxy. Your Windows browser knows the proxy, but if the Linux environment variables don't, curl and apt try to connect directly and fail. Because the symptom resembles a DNS error, people often chase the wrong cause.
The official networking page says the autoProxy setting in .wslconfig, on Windows 11 22H2 and later, makes WSL use the Windows HTTP proxy information. The troubleshooting page adds that WSL then sets HTTP_PROXY, HTTPS_PROXY and NO_PROXY in Linux. With a PAC file, however, WSL only sets a single variable, and Linux does not support PAC proxies by default.
So on a proxied network, start with env | grep -i proxy and check whether the variables hold values. If they are empty, review autoProxy. If your company uses PAC, ask IT for the direct proxy address.
Why does a Docker container have no internet when WSL2 does?
This is more of a Docker issue than a WSL issue. The official troubleshooting page states that DNS queries from containers managed by Docker Desktop bypass DNS tunneling, and Docker Desktop applies host DNS settings in its own way.
So if resolution works in your WSL shell but not inside a container, editing resolv.conf won't help. Check which network the container joins and how Docker handles DNS first. For a refresher on the basics, see our Docker containers guide.
Another typical blocker when you run Docker inside WSL is a permissions error; we cover it in our article on the docker.sock permission denied error and its safe fix. Also, if you build your dev environment in containers, a VS Code dev container helps you pin network settings per project.
Example scenario: apt update stalls when the VPN connects
This is an example scenario, not a real person's case. A developer works from home on Windows 11 and connects to the company VPN. With the VPN off, Ubuntu on WSL downloads packages without trouble. With the VPN on, apt update stalls because it cannot resolve server names.
The first test shows that ping 1.1.1.1 answers while the domain ping does not. That confirms a DNS issue. Next, the developer opens resolv.conf and finds a public DNS address copied from a forum long ago; wsl.conf contains generateResolvConf=false. Under company policy, that server does not answer while the VPN is up.
The fix runs like this. First, the developer removes the line from wsl.conf so WSL generates the file again. Then they confirm that .wslconfig does not turn dnsTunneling off, and they run wsl --shutdown. After the restart, resolv.conf shows the tunneling address, and resolution works with the VPN on and off. In short, the cure is not a new setting; it is undoing an old "temporary" fix.
What are the most common mistakes?
In our experience, what drags out WSL2 networking issues is rarely the original fault. It is the pile of fixes on top of it. Avoid these mistakes:
- Editing resolv.conf without turning off generateResolvConf, then wondering why the change vanishes.
- Turning off generateResolvConf and still expecting DNS tunneling to work.
- Writing a wsl.conf key into .wslconfig, or the other way around.
- Testing without running
wsl --shutdownafter a change. - Leaving the VPN DNS server in resolv.conf after you disconnect.
- "Fixing" a work laptop by switching the firewall off.
- Trying to fix Docker container DNS through the WSL resolv.conf.
Also, back up each file before you change it. For example, a single sudo cp /etc/wsl.conf /etc/wsl.conf.bak makes it easy to roll back when a change goes wrong.
How do you confirm the problem is really gone?
However, one working ping is not enough proof. Some problems appear only for certain domains, only with the VPN on, or only after a restart. Use this short checklist to make the fix solid:
- Both the IP ping and the domain ping succeed.
apt update, or your package manager, finishes without errors.- Results stay the same after
wsl --shutdownand a fresh start. - You tested with the VPN on and with it off.
- Internal company hostnames resolve if you need them.
To see how a domain looks from outside your machine, use our DNS lookup tool. That helps you tell whether the issue lives on your computer or in the domain's own records.
What information should you collect before asking for help?
If you cannot solve it yourself, prepare the facts before you contact IT or open an issue in the official WSL repository. Microsoft's troubleshooting page also suggests searching existing issues first and attaching networking logs when needed.
Specifically, collect these details in one note:
- Output of
wsl --versionand your Windows version. - Distro name and output of
wsl --list --verbose. - Contents of /etc/wsl.conf and .wslconfig, with any secrets masked.
- Contents of /etc/resolv.conf and whether it is a link.
- Results of the IP ping and the domain ping.
- Whether the issue occurs with the VPN on, off, or both.
This list answers the usual "can you try this first" questions up front. It also serves as your own record; if the issue returns months later, you will remember what you changed. Mask internal hostnames and IP addresses before you post anything on a public forum.
If the browser shows DNS errors too, is WSL the problem?
No, in that case the issue is probably not specific to WSL. If your Windows browser also shows an error like DNS_PROBE_FINISHED_NXDOMAIN, look at Windows network settings, your router or the domain itself. For that scenario, our guide to fixing DNS_PROBE_FINISHED_NXDOMAIN is a better starting point.
If DNS terms feel fuzzy, our web hosting terms glossary explains name servers, record types and TTL in plain language. For further reading, the article on anycast DNS shows how public resolvers work behind the scenes.
Once networking works again, many developers pick up where they left off and run into a package manager error next. For example, if a Node.js project hits a dependency conflict, our guide to the npm ERESOLVE error can help.
When should you move from WSL2 to a real Linux server?
WSL2 is a strong tool for local development, but it is not a production environment. If you want an app to run continuously where other people reach it, tying its network layer to Windows adds needless risk. A Linux server gives you more predictable network behavior.
If you plan that move, our guide on how to install Ubuntu Server and handle the initial setup offers a clear roadmap. On the other hand, if you stay with local development, keep the diagnostic order from this guide as a note: IP test, domain test, resolv.conf, wsl.conf, .wslconfig, and finally VPN and firewall.
At Talha Aslan and team, we follow the same principle in development environments: measure first, change one thing, then measure again. With a WSL2 no internet problem, that approach turns hours of trial and error into a few minutes of diagnosis.



