TroubleChute Logo
WSL

Fix apt "invalid for another" or "unable to fetch packages" error


Published: Jan 26, 2023
Last Edit: Feb 24, 2024
Ubuntu
257 Words, 1 Minute.

The issue

Can’t run sudo apt update or sudo apt-get update because you’re getting errors that look like the following in WSL?

1
2
3
E: Release file for http://security.ubuntu.com/ubuntu/dists/jammy-security/InRelease is not valid yet (invalid for another 27min 35s). Updates for this repository will not be applied.
E: Release file for http://archive.ubuntu.com/ubuntu/dists/jammy-updates/InRelease is not valid yet (invalid for another 7min 28s). Updates for this repository will not be applied.
E: Release file for http://archive.ubuntu.com/ubuntu/dists/jammy-backports/InRelease is not valid yet (invalid for another 8min 8s). Updates for this repository will not be applied.

How about Ubuntu apt-get unable to fetch packages? Well, this guide should help.

The solution

Well, the answer is simple. WSL has its time desynchronized from Windows. Simply run:

1
2
sudo apt install ntpdate
sudo ntpdate -v pool.ntp.org

And you should now be able to run

1
2
3
sudo apt update
# or
sudo apt upgrade

to your hearts content.

Heck, sometimes even just installing other software using dpkg fails.

ALSO

Have a look at the time on Windows, vs a clock or phone. Is it the same? Make sure to double-check your Windows time and timezone, even if you think it’s correct!

Other solutions

The above worked for me, but these are the other solutions I found while trying to fix this.

1
2
3
4
5
sudo nano /etc/resolv.conf

# Now add the following, Save with Ctrl+S, Ctrl+X, and try again
nameserver 8.8.8.8
nameserver 8.8.4.4
1
sudo hwclock -s
1
2
# As a temporary workaround
apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update
TroubleChute © Wesley Pyburn (TroubleChute)
Support Me Privacy Policy Cookies Policy Terms of Service Change privacy settings Contact