(For people who like to hibernate/sleep rather than reboot.)
So after keeping you machine running for some days, weeks, or in unlikely cases maybe months without a reboot, you might notice that wsl has trouble retrieving packages from the web and maybe even other strange problems.
This might be related to “clock skew”, an issue where the clock in WSL (2) desynchronizes with the host clock.
There’s an easy fix which sadly requires you to run a sudo-ed script in wsl on startup.
So, let’s start by disabling the sudo password
And now we should open a new WSL 2 instance, this should locate us in our userprofile directory (user home).
Run following command
sudo nano .bashrc
Then add following line to the end of the file
sudo ntpdate ntp.ubuntu.com &>/dev/null
now press CTRL + O and exit the script
After the next WSL instance start, you should not have a clockskew problem anymore.
Leave a Reply