This suddenly just happened. The only significant change I did was running WSL with Docker for Desktop. I was able to run apps inside the Docker container and access them from the Windows host but then I noticed I can no longer access the non-docker apps. They suddenly returned ERR_NO_RESPONSE (or something, I forgot) and ERR_CONNECTION_RESET when trying to access them by localhost:port.
Things I have tried:
Uninstalled docker
Removed entries added by Docker in Windows hosts file (C:\Windows\System32\drivers\etc\hosts)
Reinstalled WSL
What worked
But what worked is that I have to run this powershell script starting WSL.
Previously, I never had to do this, I only ran this once before and opening localhost:port apps never had an issue. Only recently after touching Docker that I have to run this every time.
You can run the script by opening CMD as admin. This will add Inbound and Outbound rules in the Firewall for WSL.
When trying to run the command in CMD, you might encounter an error ifconfig: command not found. To fix this, run sudo apt install net-tools inside WSL. This will also make ifconfig accessible to CMD.
So my new workflow right now is:
Open WSL
Run the powershell script
Run the apps and access them on localhost
A bit tedious but 🤷♂️.
Default Values
For reference, I ended up not touching these files. I read some solutions that changed these files but not on my case.
If your WSL can’t access the internet, change the nameserver to 8.8.8.8.
This is still Day 0 of the workaround and I still need to reinstall Docker again. So we’ll see.
Update history:
Oct 26, 2022 - add sudo apt install net-tools
Dec 05, 2024 - I haven’t experienced this since then. I’m also on Windows 11 now