Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Server clock wrong: fix expired tokens and broken cookies

OPS-022Low impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

Your web server keeps its own clock. When that clock is minutes, hours or days off, anything that depends on the time can misbehave. This is called clock drift (slow slide away from true time) or a wrong date set by hand or after a restart.

Things that rely on the server time include login sessions, cookie expiry dates, JWT tokens (signed login or API tokens with start and end times), signed URLs, HMAC-signed API requests, SSL/TLS certificate checks, scheduled jobs and log timestamps.

Why it costs you leads or sales

The business impact is usually low, but when it hits, it hits quietly. Nothing looks down, yet some steps fail.

Typical symptoms of a wrong clock
  • Visitors get logged out straight after logging in, because the session cookie is set with an expiry that is already in the past.
  • Cart or checkout sessions vanish, so shoppers see an empty basket.
  • Payment, CRM or email APIs reject requests with errors such as 'timestamp out of range', 'token expired' or 'token not yet valid'.
  • Password reset and magic-link emails say the link has expired when it was just sent.
  • Scheduled posts, emails or backups run at the wrong time or not at all.
  • Reports and logs show leads at the wrong hour, which makes lead tracking and attribution harder to trust.
How a wrong clock breaks a lead journey
  1. Visitor submits formPage loads and form is sent
  2. Server signs requestTimestamp is 2 hours ahead
  3. CRM API checkRejects: timestamp out of range
  4. Lead savedNever arrives

Example: the server clock is 2 hours fast, so a token issued by the server is rejected by the CRM.

A drifted clock turns a working step into an error

The page looks fine, but the signed request fails behind it.

How to check if your site has it

Check the server time
  1. Read the server time

    Log in to the server over SSH and run date -u for UTC time. On a managed host with no SSH, look for a server info or status page, or a tool such as WordPress Site Health or a PHP info page that shows the date.

  2. Compare to a trusted source

    Compare the result with the UTC time from a public time site or your own computer (which syncs automatically). More than a few seconds of difference is worth fixing. Minutes is a real problem.

  3. Check sync statusCustom code

    On Linux with systemd run timedatectl. Look for 'System clock synchronized: yes' and 'NTP service: active'.

  4. Check the Date header

    Run curl -sI https://example.com | grep -i '^date' and compare the Date header to real UTC time. This shows what the web server tells visitors.

  5. Read the error messages

    Search your logs for phrases such as 'token expired', 'not yet valid', 'timestamp', 'clock skew' or 'iat'. These point to time problems.

Quick clock checks on a Linux serverbash
date -u
timedatectl
curl -sI https://example.com | grep -i '^date'

How to fix it

The fix is almost always the same: let the server keep time automatically using NTP (Network Time Protocol, a standard way for computers to get the correct time from trusted servers), keep the server in UTC, and set the time zone only where people need local time.

Fix the clock by platform
  1. Turn on NTP

    On systemd Linux run sudo timedatectl set-ntp true. On older systems install and start chrony or ntpd.

  2. Set the time zone

    Run sudo timedatectl set-timezone UTC, or your chosen zone. Keeping servers on UTC avoids daylight saving surprises.

  3. Restart time-dependent services

    Restart PHP-FPM, your app and any queue workers so they stop using stale state. Clear sessions that were created with wrong dates.

  4. Virtual machines and containers

    Containers use the host clock, so fix the host. On virtual machines, make sure the hypervisor's time sync or the guest NTP is on, but not both fighting each other.

Before and after fixing the clock

Clock 2 hours fast, no sync

  • Session cookies expire straight away
  • API calls fail with 'timestamp out of range'
  • Reset links show as expired

NTP on, UTC set

  • Cookies last as long as intended
  • Signed API calls are accepted
  • Links and scheduled jobs run on time

How to confirm it's fixed

Confirm the fix
  • date -u matches a trusted UTC source within a second or two.
  • timedatectl shows 'System clock synchronized: yes'.
  • The Date header from curl -sI matches real time.
  • You can log in, stay logged in and complete a test checkout or form.
  • The earlier 'token expired' or 'timestamp' errors stop appearing in new log entries.
  • A password reset link works when opened right away.

How to prevent it happening again

Keep the clock right
  • Keep NTP or chrony enabled on every server, including staging and worker machines.
  • Run servers in UTC and convert to local time only when showing it to people.
  • Add a clock drift alert to your server monitoring, for example when offset passes a few seconds.
  • Check the clock after restoring a backup, cloning a virtual machine or moving hosts.
  • Allow a small clock skew tolerance when validating tokens and signatures.
  • Use more than one time source in your NTP config so one outage does not stop sync.

How FunnelGuard handles this

This issue is outside what FunnelGuard checks. FunnelGuard is a synthetic monitoring service: a robot visitor runs your real customer journeys from outside your site, and checks steps, tracking hits and test leads. It does not read your server's internal clock or measure time drift.

The kind of tool that fits is server or infrastructure monitoring (an agent on the server that reports clock offset and NTP status), or your host's own monitoring. Set an alert on time offset there.

A wrong clock can still show up as a failed form, a broken checkout step or a lead that never reaches the CRM. Scheduled FunnelGuard journey runs are useful for seeing that a journey failed, but they will not tell you the clock is the cause, so you still need to check the server time yourself.

Questions people ask

Why are my cookies expiring immediately?

If the server sets a cookie expiry using a clock that is ahead or behind, the date can land in the past for the visitor's browser. Check the server time with date -u and compare it with real UTC time. Fix the clock and clear old sessions.

Why does my API say 'token expired' right after I created it?

The clock on the machine that issued the token and the clock on the machine checking it are different. Tokens such as JWTs carry start and end times, so a drift of even a few minutes can make a new token look expired or not yet valid. Sync both machines with NTP and allow a small skew tolerance.

How do I check if my server time is correct?

Run date -u on the server and compare it with a trusted UTC time source. On Linux with systemd, timedatectl also shows whether the clock is synchronized. You can see what the web server reports by checking the Date header from curl -sI.

How do I fix the server time on Linux?

Run sudo timedatectl set-ntp true to turn on automatic time sync and sudo timedatectl set-timezone UTC to set the zone. On systems without systemd, install and start chrony or ntpd. Then restart apps that depend on time.

Can a wrong server clock break SSL or HTTPS?

Yes. If the server clock is far off, it may treat a valid certificate as not yet valid or expired when it connects to other services, and outgoing HTTPS calls can fail. Browsers use the visitor's clock, so visitors with a wrong device date can see certificate warnings.

Can I fix the server clock on shared hosting or WordPress hosting?

Usually not. On shared or managed hosting the provider controls the system clock. Check Universal time in WordPress under Settings > General, then send your host the evidence and ask them to fix it.

Does FunnelGuard detect a wrong server clock?

No. This is outside what FunnelGuard checks, because it needs a tool that reads the server itself. Use server or infrastructure monitoring that reports clock offset and NTP status.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.