While working on an ecommerce marketplace project, one day all my product images that are stored on Amazon S3 ,via django-storages, are all down! Nightmare!
Upon researching, I realized the issue is that the time of my linux server is out of synced with Amazon's system clocks. Amazon S3 uses NTP (Network Time Protocol) to keep its system clocks accurate. NTP provides a standard way of synchronizing computer clocks on servers.
This is the error message I encountered:
Error executing "PutObject" on "https://s3.ap-southeast-1.amazonaws.com/s3.XXXX-YOUR-BUCKET-LINK-XXXX"; AWS HTTP error: Client error: `PUT https://s3.ap-south-1.amazonaws.com/s3.XXXX-YOUR-BUCKET-LINK-XXXX` resulted in a `403 Forbidden` response:
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>RequestTimeTooSkewed</Code><Message>The difference between the reque (truncated...)
RequestTimeTooSkewed (client): The difference between the request time and the current time is too large. - <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>RequestTimeTooSkewed</Code><Message>The difference between the request time and the current time is too large.</Message><RequestTime>20180817T035220Z</RequestTime><ServerTime>2018-08-17T06:17:43Z</ServerTime><MaxAllowedSkewMilliseconds>900000</MaxAllowedSkewMilliseconds><RequestId>1BF4E523584F893B</RequestId></Error>
Let's start by looking at Amazon S3 server time.
$ curl http://s3.amazonaws.com -v
Then to check our own Linux server time, we can use
$ date
Have a look at the time discrepancies, which is the source of the error.
Now let's install ntp
sudo apt-get install ntp
Then open the ntp config file located in /etc/ntp.conf and replace the existing entries with the following:
Type this command to open the ntp config on your terminal:
vi /etc/ntp.conf
Existing Entries in ntp config file:
server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org
Replace with the following below:
server 0.amazon.pool.ntp.org iburst
server 1.amazon.pool.ntp.org iburst
server 2.amazon.pool.ntp.org iburst
server 3.amazon.pool.ntp.org iburst
Now make sure you are in the root to run the final command.
If you have forgotten your root password, follow this:
$ sudo passwd root
You will see the following prompt on your terminal to update the password.
[sudo] password for <user>:
New password:
Retype new password:
passwd: password updated successfully
Once you have updated your root password, type this:
$ su -
Enter your new root password when prompt.
Then finally, in root, you can type in the final command to resolve the error.
root@DESKTOP-ABCDEF:~# service ntp restart
You will see the NTP server restarting.
* Stopping NTP server ntpd [ OK ]
* Starting NTP server ntpd [ OK ]
Go back to your project and magic has happened!
After encountering this error, i felt it is a good time to update myself on cloud computing knowledge! I found a decent online course on Coursera Shall start with this one day!
Thanks for reading!
Top comments (1)
hi,i had the same error and just changed the "date and time " of the windows from analog to automatic...