// libSQL error reference

auth token expired: Auth token expired

The JWT the connection presents passed its exp claim, so the server answers 401 until you mint a new token.

오류
auth token expired
카테고리
Authentication and tokens
오류 메시지
401 Unauthorized: auth token is invalid or expired

의미

Turso auth tokens are JWTs with an expiry. turso db tokens create tokens never expire by default: an expiry exists only when the token was minted with --expiration (or is a platform token with a built-in lifetime). When the exp claim passes, the server rejects the token with 401. The failure shows up as SERVER_ERROR: Server returned HTTP status 401 Unauthorized, and the cause is visible in the token itself.

일반적인 원인

  • The token was minted with --expiration and aged past it, and the config was never refreshed.
  • A CI secret stores a token with a short expiry and the job runs after it lapsed.
  • A long-lived server process loaded a token at startup and never reloads it.

Find the cause

Decode the JWT payload and read `exp` (seconds since epoch). Compare with `date +%s`. An `exp` in the past confirms expiry. If `exp` is in the future but the server still answers 401, the token is not expired: look at database mismatch instead, which is the 401 entry's other causes.

해결 방법

  1. Mint a fresh token and update the config:

    turso db tokens create mydb --expiration 30d
  2. For services, refresh the token at startup and periodically instead of baking it in:

    // re-read env or re-mint on 401 before giving up
    if (String(err).includes('401')) token = await mintToken();
  3. Check the expiry inside the current token:

    echo "$LIBSQL_TOKEN" | cut -d. -f2 | base64 -d 2>/dev/null | grep -o '"exp":[0-9]*'; date +%s

Other ways to handle it

The default token never expires, which is convenient and dangerous: a leaked default token is valid until you revoke it with turso db tokens invalidate. Prefer short-lived tokens minted at deploy time.

안전하게 재현하세요

Honest repro needs a cloud database: create one with `turso db create repro-exp`, mint a token with `--expiration 1s`, wait a few seconds, then connect. The server answers 401. Offline you can verify only the decode step: a token with a past `exp` is demonstrably expired without any server.

질문

How long do Turso auth tokens last?

Database tokens from turso db tokens create never expire unless you pass --expiration when minting them. If a token has an exp claim that passed, it was minted with a deliberate expiry.

How do I rotate an expired or leaked Turso token?

Mint a fresh one with turso db tokens create mydb --expiration 30d, update every consumer, then revoke the old one with turso db tokens invalidate mydb so copies in old configs stop working.

관련 오류

More authentication and tokens errors

코드와 메시지 텍스트의 출처는 다음과 같습니다 libSQL / Turso documentation. 전체 목록은 libSQL error list 또는 모든 데이터베이스 오류 검색.

// 오류는 줄이고, 수정은 빠르게

Work on libSQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for libSQL and the other databases you use.

이 페이지의 텍스트와 데이터: CC BY 4.0, 출처: SQLly (sqlly.app). 코드와 SQL 스니펫: MIT. 라이선스 세부 정보 인용된 오류 메시지 텍스트의 권리는 해당 데이터베이스 공급업체에 있습니다.