Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Internet when winnat stop/started #9418

Closed
1 of 2 tasks
foremtehan opened this issue Jan 1, 2023 · 7 comments
Closed
1 of 2 tasks

No Internet when winnat stop/started #9418

foremtehan opened this issue Jan 1, 2023 · 7 comments
Labels

Comments

@foremtehan
Copy link

foremtehan commented Jan 1, 2023

Version

Microsoft Windows [Version 10.0.19044.2364]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.16

Distro Version

Ubuntu 22.04

Other Software

Docker Desktop (Engine) v20.10.17

Repro Steps

I was on the stackoverflaw for solving this problem:

bind: An attempt was made to access a socket in a way forbidden by its access permissions

I ran:

net stop winnat
net start winnat

The issue will go away but the WSL's internet interrupted and i have to reboot the pc

First, Can you tell me why the first error happens? It occur when the windows restarted, The second one cause by the 1st solution :(

Expected Behavior

Having Internet on WSL after stop/start winnat

Actual Behavior

No Internet After:

net stop winnat
net start winnat

$ curl google.com

curl: (6) Could not resolve host: google.com

Diagnostic Logs

No response

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 6, 2023

Thanks for reporting this @foremtehan.

WSL uses HNS for NAT networking, which relies on winnat. I'm guessing that restarting winnat will drop all the port reservations which will effectively break any running WSL2 distribution.

@foremtehan
Copy link
Author

foremtehan commented Jan 6, 2023

Ok how do i solve bind: An attempt was made to access a socket in a way forbidden by its access permissions issue then? Is it possible to fix it without restarting the pc ?

Every solution on internet require restarting pc or restarting winnat

@ReSpawN
Copy link

ReSpawN commented Mar 13, 2023

I am having the same problem which is also talked about in this thread.
docker/for-win#3171

@JosueAChavez
Copy link

Any solution to this? This seems to permanently break the WSL because rebooting and restarting wsl.exe doesn't work.

@Ai-Yukino
Copy link

Ai-Yukino commented Feb 20, 2024

FYI, this solution in #3438 worked for me. For whatever reason, you have to make sure to actually restart instead of shutting down and powering back on

@dori4n
Copy link

dori4n commented Nov 12, 2024

What @Ai-Yukino wrote above leads to instructions to reset your entire network configuration. This doesn't work, and especially is no solution to WSL network connectivity issues (typically of the type, DNS works, but ICMP, TCP and UDP don't) after restarting the WinNAT service, which is a common solution for freeing a listen port that it is hogging for some reason, so that a Windows application may use it.

Since I find it beyond annoying to have to go hunt for solutions and a non-solution (generic nuclear option of "just reinstall" or "just reset to default settings") being offered in all the popular internet search results, here's the correct solution. Requires no reboot or reconfiguring all of your network settings, either:

After restarting WinNAT with net stop winnat && net start winnat, it will also be necessary to restart the Host Network Service with net stop hns && net start hns. However, be aware that the Application Guard Container Service depends on it. If Windows Defender Application Guard is installed, you will need to stop it before stopping the Host Network Service with net stop hvsics and then restart it after, as well with net start hvsics.
It is also necessary to stop WSL with wsl --shutdown and reopen your WSL terminal after doing the above or networking will still not work properly.

You're welcome.

@Ai-Yukino
Copy link

Thanks for providing correct solution @dori4n ! I appreciate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants