Hello
Thank you for your question and reaching out. I can understand you are having issues related to Internet connection to WSL.
The reason this error occurs is because Windows automatically generates resolv.conf file with wrong nameserver.
On your Windows Machine run following commands.
netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns
On your WSL Terminal :
Locate the file by running the following command:
sudo nano /etc/resolv.conf
This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/resolv.conf
[network]
generateResolvConf = false
nameserver 8.8.8.8
--If the reply is helpful, please Upvote and Accept as answer--