Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WSL throws (6) Could not resolve host: raw.githubusercontent.com when trying to install NVM and cant ping google.com

When trying to install nvm with wsl 2 on windows 11, it throws:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:09 --:--:--     0curl: (6) Could not resolve host: raw.githubusercontent.com

when I try to ping google.com it errors, while ping 8.8.8.8 works!?!

like image 390
Matt Jaf Avatar asked Sep 06 '25 03:09

Matt Jaf


1 Answers

you can try running this

sudo rm /etc/resolv.conf
sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "[network]" > /etc/wsl.conf'
sudo bash -c 'echo "generateResolvConf = false" >> /etc/wsl.conf'
sudo chattr +i /etc/resolv.conf

it deletes your resolve.config file thats automatically generated when u run WSL then creates a new file and puts "nameserver 8.8.8.8", then creates a wsl.conf file and adds [network] and generateResolveConf = false to prevent auto generation of that file

you can also run

cat /etc/resolv.conf

to check the contents of the file

than

ping google.com
like image 57
Matt Jaf Avatar answered Sep 07 '25 22:09

Matt Jaf