ecdsa.com
jsonwebtoken (Node.js)JWT libraries

Error message

jwt expired

What it means

jsonwebtoken's TokenExpiredError: the token's exp claim (a Unix timestamp in seconds) is earlier than the verifier's current clock. The signature itself may be perfectly valid — the token has simply outlived the lifetime the issuer gave it. The error object carries expiredAt with the exact moment.

Why it happens

How to fix it

  1. 1.

    Allow small skew explicitly

    clockTolerance accepts seconds and applies to exp and nbf. Keep it small (30–60 s) — it exists to absorb clock drift, not to extend token lifetimes.

    js
    jwt.verify(token, publicKey, {
      algorithms: ["ES256"],
      clockTolerance: 30, // seconds of tolerated skew
    });
  2. 2.

    Inspect exp before blaming the clock

    Decode the claims and print exp next to your current time. If exp looks like 1.7e12 you have a milliseconds bug; if it is minutes in the past, you need refresh logic.

    js
    const { exp } = jwt.decode(token);
    console.log("exp:", new Date(exp * 1000).toISOString());
    console.log("now:", new Date().toISOString());
  3. 3.

    Sync clocks and add a refresh path

    Run NTP (chrony/systemd-timesyncd) on verifying hosts, and implement token refresh on 401 responses client-side. Never ship ignoreExpiration: true to production — it turns every leaked token into a permanent credential.

Related errors

← Browse the full signature error database