I'm trying to upload files to an S3 bucket via a laravel app
I get the following error:
S3Exception in WrappedHttpHandler.php line 152: Error executing
"PutObject" on "https://s3-ap-southeast-1.amazonaws.com/
AWS HTTP error: Client error: 403 RequestTimeTooSkewed (client): The
difference between the request time and the current time is too large
I've done some research and many say that my my machine's time is not synced. I'm afraid of messing with homestead because im afraid of breaking something. Do i change my app timezone? Really not sure.
Please help and thank you for taking the time
You will need to update the clock on your homestead installation. You can do this using ntpd to ensure that this keeps your clock up to date as systems can suffer from a reasonable amount of time during reboots. On VMs this seems to be even more significant (but I am not sure of the details why).
To get ntpd setup and running do the following in your homestead box;
sudo apt-get install ntp
Then you need to set your timeservers. Run the following;
sudo nano /etc/ntp.conf
Then make sure the file has the following contents;
server ntp.ubuntu.com
server pool.ntp.org
Once you've saved those changes then run;
sudo service ntp restart
Once you have done this ntpd will take care of keeping your system clock correct minimising the risk of a drift error coming back from S3.
Finally I would note not to worry too much about breaking your homestead environment as it is a virtual machine. The beauty of which is you can very easily rebuild it if you get something wrong.
My website is hosted in AWS with Ubuntu 14.04.5 and Apache
I was uploading files flawless and then I started getting the same error. Error executing "PutObject" on "...." .... RequestTimeTooSkewed
So with @marcus approach I didn't see those server ntp.ubuntu.com and server pool.ntp.org files... but with the command
timedatectl
I got that my timezone was correct but:
- NTP enabled: yes
- NTP synchronized: no
The NTP was not synchronized, so I tried restarting NTP with:
sudo service ntp restart
It changed my NTP synchronized to YES and it solved the problem.