AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}Short answer
AWS compares the timestamp in your signed request with its own clock. 'Signature not yet current' means your request claims a time later than AWS expects, so the server's clock runs ahead. Check the clock and NTP status on the machine running PHP, turn time sync on, and make sure any hand-written signing code uses UTC.
Fix it fast
1Find out which cause you have
Compare the machine's idea of UTC with the real time. Run this on the host or container that runs PHP, not on your laptop.
date -u timedatectl status2Match what you see, then jump to its fix
What does the error look like?
Signature not yet current: {date} is still later than {date}
Cause 1 of 2
The server clock runs ahead of real time
1Check
timedatectl prints the synchronisation state. If it says no, the clock is not being corrected.
timedatectl status
timedatectl timesync-status2Fix
Turn on network time synchronisation. The command enables and starts the first existing time sync service on the machine.
sudo timedatectl set-ntp true3Verify
The status shows the clock as synchronized, and a new SDK call no longer fails.
timedatectl status | grep -i synchronized
date -uConfirmed by freedesktop.org
Cause 2 of 2
Hand-written signing code builds the timestamp in local time
1Check
AWS requires the timestamp in UTC in the form YYYYMMDDTHHMMSSZ. Search your code for date() or DateTime without a UTC timezone.
grep -rn "x-amz-date\|X-Amz-Date" src/ app/2Fix
Generate the stamp in UTC. Better, let the SDK sign the request instead of writing the signature yourself.
<?php
$now = new DateTimeImmutable('now', new DateTimeZone('UTC'));
$amzDate = $now->format('Ymd\THis\Z');3Verify
The x-amz-date value ends in Z and matches the output of date -u.
<?php
echo (new DateTimeImmutable('now', new DateTimeZone('UTC')))->format('Ymd\THis\Z');Confirmed by docs.aws.amazon.com
How do I stop it coming back?
- Keep time synchronisation on for every server and container host that signs AWS requests.
- Use the AWS SDK for PHP to sign requests instead of building signatures by hand.
- Add a clock-drift check to your monitoring so a drifting host is found before API calls fail.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- RaheebA consumer app shipped to both stores from one Flutter codebase on a .NET and Azure back end.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Back end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
CodeIgniter 4 cannot write its cache files
CodeIgniter\Cache\Exceptions\CacheException: Cache unable to write to /var/www/app/writable/cache/
CodeIgniter 4's file cache needs a cache directory that the web server can really write to.
2 causes, each with a fixBack end
CodeIgniter 3 loads the model but the property is undefined
The model name you are loading is the name of a resource that is already being used: user
CodeIgniter 3 expects a model file named like its class, with the first letter capitalised, for example User_model.php holding class User_model.
2 causes, each with a fixBack end
CodeIgniter 3 stops with "Your system folder path does not appear to be set correctly"
503 Service Unavailable
CodeIgniter 3's front controller resolves $system_path and then checks that the result is a directory.
3 causes, each with a fix