The Short Answer
Restart the "Host Network Service" Windows service.
How to Restart Host Network Service
This can be done in a couple of ways. It's quite easy to restart the service via the Windows UI. From Windows Start menu, choose Services, scroll to Host Network Service, right-click and choose "Restart" from the context menu
Or... you can restart the service from the Windows command line. From a Command Prompt that's running as Administrator, run the following command:
net stop hns && net start hns
I've found that network access sometimes fails within my Ubuntu on Windows environment. This not only makes it so I can't initiate network-dependent commands, such a
git pull; I also can't make calls via ngrok into the Docker environment running on Ubuntu on Windows. The first time this happened, I was stumped. My Windows applications all had Internet access, but from within WSL (Windows Subsystem for Linux), I couldn't see the outside world. I rebooted my laptop and the problem went away.
The second time this happened, I realized I needed a less obtrusive solution. I did some searching and discovered that this is typically due to a failure in the Host Network Service, and that simply restarting the service clears it up. I tried it, and it worked.
If you just searched for something like "wsl cannot connect to internet" or "I can't ping internet hosts from wsl" and landed here, I hope this helps.
If you determine the root cause of these occasional network issues, comment to let us all know!