AWS S3: The difference between the request time and the current time is too large

· 1 min read
AWS S3: The difference between the request time and the current time is too large

If system clock is out of sync, we may encounter error message like "An error occurred (RequestTimeTooSkewed) when calling the ListBuckets operation: The difference between the request time and the current time is too large."

ag@aj:~$ aws s3 ls

An error occurred (RequestTimeTooSkewed) when calling the ListBuckets operation: The difference between the request time and the current time is too large.

Fix:

I mostly use Ubuntu running on WSL for my local AWS development work and encountered this error few times

To fix, run sudo hwclock -s. It will sync up the system clock with the current time.

abhijit@awsjunkie:~$ date
Tue Jul  4 08:54:30 EDT 2023

sudo hwclock -s

abhijit@awsjunkie:~$ date Tue Jul 4 10:59:18 EDT 2023

abhijit@awsjunkie:~$ aws s3 ls 2023-07-04 10:30:51 awsjunkie-time-sync-test

Demo:

Usage of hwclock command:

hwclock -h

Usage: hwclock [function] [option…]

Time clocks utility.

Functions: -r, —show display the RTC time —get display drift corrected RTC time —set set the RTC according to —date -s, —hctosys set the system time from the RTC -w, —systohc set the RTC from the system time —systz send timescale configurations to the kernel -a, —adjust adjust the RTC to account for systematic drift —predict predict the drifted RTC time according to —date

Options: -u, —utc the RTC timescale is UTC -l, —localtime the RTC timescale is Local -f, —rtc <file> use an alternate file to /dev/rtc0 —directisa use the ISA bus instead of /dev/rtc0 access —date <time> date/time input for —set and —predict —delay <sec> delay used when set new RTC time —update-drift update the RTC drift factor —noadjfile do not use /etc/adjtime —adjfile <file> use an alternate file to /etc/adjtime —test dry run; implies —verbose -v, —verbose display more details

-h, —help display this help -V, —version display version