Bolt auth

JWT Token Validation Fails - Invalid Signature or Expiration

API requests fail with JWT verification errors even though the token appears valid. Tokens work initially but fail after some time or across different server instances.

Symptoms include immediate '401 Unauthorized' on API calls, 'JsonWebTokenError: invalid signature', or tokens expiring immediately after issue.

Error Messages You Might See

JsonWebTokenError: invalid signature Error: Token used before valid TokenExpiredError: jwt expired 401 Unauthorized: Invalid token

Common Causes

  1. Secret key mismatch between token creation and verification
  2. JWT expires too quickly or has wrong expiration time
  3. Token created with different secret than verification uses
  4. Multiple server instances using different secrets
  5. Clock skew between client and server causing 'not yet valid' errors

How to Fix It

Store JWT secret in environment variable and use identical value for both signing and verification

Set reasonable expiration: 15min for access token, 7d for refresh token

Implement token refresh: when access token expires, use refresh token to get new one without user re-logging in

Real developers can help you.

Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture Stanislav Prigodich Stanislav Prigodich 15+ years building iOS and web apps at startups and enterprise companies. I want to use that experience to help builders ship real products - when something breaks, I'm here to fix it. Pratik Pratik SWE with 15+ years of experience building and maintaining web apps and extensive BE infrastructure Simon A. Simon A. I'm a backend developer building APIs, emulators, and interactive game systems. Professionally, I've developed Java/Spring reporting solutions, managed relational and NoSQL databases, and implemented CI/CD workflows. Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact. Mehdi Ben Haddou Mehdi Ben Haddou - Founder of Chessigma (1M+ users) & many small projects - ex Founding Engineer @Uplane (YC F25) - ex Software Engineer @Amazon and @Booking.com rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems Matt Butler Matt Butler Software Engineer @ AWS Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever Jaime Orts-Caroff Jaime Orts-Caroff I'm a Senior Android developer, currently working at Aircall. I'm open to work in various fields!

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

What's a good JWT expiration time?

Access tokens: 15 minutes. Refresh tokens: 7 days. This balances security with user experience

How do I implement token refresh?

Store refresh token in secure httpOnly cookie. When access token expires, send refresh token to /api/refresh endpoint to get new access token

Why does my token fail on different servers?

Ensure all server instances use the same JWT secret from environment variables

Related Bolt Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help