I had the same thing happen to me and the problem solved itself in a few minutes on my Raspberry Pi.
It was due to incorrect system time, but I didn't have to do anything to fix it. I do not have ntpd or chronyd running on this system. I don't believe there is a battery in a Raspberry Pi to keep the motherboard clock running. I just had to wait for the systemd-timesyncd.service
to finish.
I think ultimately the answer to your situation is to verify your system clock is at least close to the correct time, whether it involves getting one of the NTP services to update your system clock or manually setting the time. For reference, the date command format to set the system time is:
sudo date [MMDDhhmm[[CC]YY][.ss]]
If your system runs chronyd, chronyc -n sources -v
will show you the time servers you're polling. If you're running ntpd, ntpq -np
. There should be an asterisk, *, next to an IP address. That's the time server you're synchronized with. (It should not be an address that starts with 127, though!) If there is no asterisk in the first or second column, you'll need to somehow set the time manually. You can try the hwclock
command or set the time with date
. Please be aware that even if you're running ntpd or chronyd these services can take up to several minutes to update the system clock, unless you've configured them to either immediately step the time or rapidly poll the time servers.
Details of My Situation
On December 4, 2021, I pulled my Raspberry Pi 400 out of it's backpack with the intention of updating the software. After it booted I immediately opened a terminal and ran sudo apt update
. The error I received was invalid for another 77d ...
. There was actually two of these errors listed and the second one had a different day value. Unfortunately, I cannot scroll back far enough in my terminal to get the exact error messages.
In the time it took me to run a Google search and find this StackExchange question, the systemd-timesyncd.service updated the system clock. Looking in the logs I can find this sequence of events. The first sudo apt update
produced the error messages. The second performed as expected.
Sep 17 08:48:47 rp400 sudo[6322]: pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/usr/bin/apt update
[...]
Sep 17 08:48:52 rp400 systemd[1]: systemd-fsckd.service: Succeeded.
Dec 04 23:21:04 rp400 systemd-timesyncd[353]: Synchronized to time server for the first time 163.237.218.19:123 (2.debian.pool.ntp.org).
Dec 04 23:21:05 rp400 dhcpcd[430]: wlan0: leased xxx.xxx.xxx.xxx for 86400 seconds
[...]
Dec 04 23:25:21 rp400 sudo[20143]: pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/usr/bin/apt update
A quick status check of the timesyncd service confirmed the September to December time jump.
pi@rp400:~ $ systemctl status systemd-timesyncd.service
systemd-timesyncd.service - Network Time Synchronization
[...]
Active: active (running) since Fri 2021-09-17 08:48:23 CDT; 2 months 17 days ago
[...]
Status: "Synchronized to time server for the first time 163.237.218.19:123 (2.debian.pool.ntp.org)."
[...]
Sep 17 08:48:22 rp400 systemd[1]: Starting Network Time Synchronization...
Sep 17 08:48:23 rp400 systemd[1]: Started Network Time Synchronization.
Dec 04 23:21:04 rp400 systemd-timesyncd[353]: Synchronized to time server for the first time 163.237.218.19:123 (2.debian.pool.ntp.org).
I can see the same thing happening to a virtual host that was suspended for a long time.