This error occurs when your system's clock is significantly out of sync with the actual time. The apt repository rejects package updates because the release file appears invalid for your system's perceived date. Fix it by synchronizing your system clock.
When you run `apt update` (or `apt-get update`), the apt package manager validates repository release files using cryptographic signatures. Each release file is signed with a specific date. If your system's clock is set to a time in the past (before the release file's signature date), apt rejects the file as "not valid yet." This commonly happens after: - System hibernation/suspend with incorrect hardware clock - Fresh Linux installation in VMs (especially WSL on Windows) where the system time drifts from the host - Timezone misconfigurations - Battery-backed CMOS clock failures on physical machines The repository server is telling you: "I created this release on DATE X. Your system claims the date is DATE Y (in the past). Therefore this release is not yet valid for you."
First, verify that your system clock is actually incorrect:
date
timedatectlThe date command shows your system's current date/time. The timedatectl command shows time sync status and timezone info. If the date is clearly in the past (days, months, or even years ago), proceed to the next step.
On Windows, you can also check the actual current time as a reference point.
If your system clock is behind the hardware clock (common in WSL and VMs), synchronize them:
sudo hwclock --hctosysThe --hctosys flag means "hardware clock to system clock" — it reads the hardware clock (CMOS) and sets the system clock to match. If your hardware clock is correct, this instantly fixes the issue.
After running this command, verify the time changed:
dateIf manual sync helped but you want to prevent future drift, enable automatic time synchronization:
sudo timedatectl set-ntp trueThis enables Network Time Protocol (NTP), which automatically syncs your system clock with internet time servers. The status changes to "System clock synchronized: yes".
Verify it's active:
timedatectlIf NTP is available but not running, you may need to install an NTP client:
sudo apt update
sudo apt install systemd-timesyncd
sudo timedatectl set-ntp trueIf your timezone is incorrect, set it to the right one:
timedatectl list-timezones # List available timezones
sudo timedatectl set-timezone Asia/Kolkata # Example: set to Indian timeVerify it was set:
timedatectl
dateAfter correcting timezone, verify it's UTC (Ubuntu's recommended default) for servers, or your local timezone for desktops.
Once your system time is correct, run:
sudo apt updateThe error should now be gone. If it persists, there may be another issue (like a corrupted GPG key for a specific PPA). In that case, the error message will be more specific about which repository is problematic.
In Windows Subsystem for Linux (WSL), the system clock can drift after hibernation. To auto-sync on every startup, add this to your WSL distro's startup:
Create or edit /etc/wsl.conf:
[boot]
command = hwclock --hctosysAlternatively, create a shell alias to sync manually whenever needed:
echo "alias fix-time='sudo hwclock --hctosys'" >> ~/.bashrcThen use fix-time as needed.
Clock Skew in Virtual Machines:
When using VirtualBox, VMware, Hyper-V, or QEMU, the guest OS time can drift away from the host. Using dynamic clock adjustment (e.g., VMware Tools, VirtualBox Guest Additions) helps. On KVM/QEMU, ensure the time source is set correctly in VM configuration.
WSL-Specific Behavior:
WSL2 uses Hyper-V internally and can lose time during host hibernation. The /etc/wsl.conf startup command is the cleanest fix. Note that WSL1 doesn't have this issue as severely, but WSL2 makes it common.
Server Deployments:
Always ensure NTP is installed and running on servers. Many cloud providers (AWS, Azure, GCP) maintain time servers that your instance can use. Disable hardware RTC if you're in a cloud VM to avoid confusion.
Corporate Proxies / Firewall Issues:
If NTP (UDP port 123) is blocked by your firewall, time sync will fail silently. Contact your network administrator to allow NTP traffic, or manually set the time periodically.
Repository-Specific Errors:
If only one PPA or custom repository fails with this error (not all repos), the issue might be with that specific repository's release file, not your system clock. Check the error message for which URL failed.
E: Could not connect to proxy server
Could not connect to proxy server
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt
E: The value 'value' is invalid for APT::Default-Release
How to fix invalid APT::Default-Release value in APT
dpkg: error: unable to create new file 'path': Permission denied
How to fix dpkg permission denied errors in APT
subprocess installed post-removal script returned error exit status 1
How to fix "subprocess installed post-removal script returned error exit status 1" in APT