Guide
"Invalid Refresh Token: Refresh Token Not Found" in Supabase: how to fix it
How this guide was made: Written with AI assistance and checked against the sources linked on this page.
Updated
Short answer: Supabase shows "AuthApiError: Invalid Refresh Token: Refresh Token Not Found" (code refresh_token_not_found) when the session holding that refresh token no longer exists. "Already Used" means the token was reused after the 10-second reuse window. Find which cause applies, then fix the code that refreshes or stores the session.
Login, emails or payments broke in your live app? Our AI agent fixes it in your code, then tests your live app again.
Your app signs a user in, then a later request fails with "Invalid Refresh Token". The string appears in GitHub reports for supabase-js and auth-js, for example supabase/auth-js #454 and supabase/supabase-js #805.
Something broke on your live app? Tell us what broke. Our AI agent tries it on your live app and sends you a screenshot, free. Check my app free
What does it mean?
Supabase gives each session a refresh token. The docs say that "refresh tokens never expire but can only be used once", and that you "can exchange a refresh token only once to get a new access and refresh token pair" (Supabase: User sessions). Each refresh therefore replaces the token, and an older copy stops working.
There is one exception. A refresh token "can be used more than once within a defined reuse interval", which is "10 seconds" by default, and the docs say "we do not recommend changing this value" (Supabase: User sessions). Outside that interval, the docs say "the whole session is regarded as terminated and all refresh tokens belonging to it are marked as revoked" (same page).
The error codes map to these two states. refresh_token_already_used means the token "has been revoked and falls outside the refresh token reuse interval". refresh_token_not_found means the "session containing the refresh token not found" (Supabase: Auth error codes). The code names are official. The message text shown in your app is what the GitHub threads quote.
Which cause is it?
| What you see | Cause | Fix |
|---|---|---|
| Invalid Refresh Token: Already Used | Two refreshes used the same token, for example two tabs or two server requests | Cause 1: two refreshes use the same token |
| Invalid Refresh Token: Already Used, after an upgrade or a timer | A timer kept a stale copy of the token | Cause 2: a timer refreshes with a stale token |
| refresh_token_not_found | The session was ended (signed out, revoked, or timed out) | Cause 3: the session was ended |
Work through the causes in order. Cause 1 and Cause 2 are the reuse errors. Cause 3 covers the not-found error.
Cause 1: two refreshes use the same token (Already Used)
The reuse window is 10 seconds. A second refresh with the same token that lands after that window fails with "Already Used". The docs give the reason for the window: it covers "server-side rendering where the same refresh token needs to be reused on the server and soon after on the client", and "some leeway for bugs or issues with serializing access to the refresh token request" (Supabase: User sessions).
The GitHub thread in auth-js #454 shows the same pattern across tabs. One tab burns the shared token, and another tab's timer-based refresh fails once the window has passed.
How to fix it
- List every place that refreshes the session: each browser client, the server proxy or middleware, server components or route handlers, and any background timer.
- Check whether two of them can run for the same user at the same time, for example two open tabs or a page load that fires two requests.
- Keep one place that refreshes. Make the other places read the current session rather than call the refresh again. The docs say the reuse window exists for server rendering that reuses the same token "soon after" on the client, so our suggestion is that the server and the browser share one refreshed token rather than each refreshing.
- Check the supabase-js version in your
package.json. Cause 2 explains the release that fixed a stale-token timer.
Source: Supabase: User sessions, supabase/auth-js #454
Cause 2: a timer refreshes with a stale token (Already Used)
In auth-js #454, a maintainer wrote that "the session passed into the _startAutoRefreshToken method can possibly become stale and fall outside the reuse interval". Contributors found that scheduled refreshes used the refresh token captured when the timer was set, not the latest one. The fix was merged in PR #461 and released in 2.0.0-rc.7. The issue was then closed as completed.
How to fix it
- Check the installed supabase-js version in your project. If it is older than 2.0.0-rc.7, update it to the current release.
- Rebuild and deploy the app, then repeat the steps in the checks section below.
- If the error still appears after the update, go back to Cause 1 and look for a second place that refreshes the same session.
Source: supabase/auth-js #454
Cause 3: the session was ended, so the refresh token is not found
The error code refresh_token_not_found means the session that holds the token no longer exists. The related code session_not_found is described as happening "if the user has signed out, or the session entry in the database was deleted in some other way". session_expired is described as occurring "if an inactivity timeout is configured, or the session entry has exceeded the configured timebox value" (Supabase: Auth error codes).
A session also ends when a token is reused outside the window. The docs say the whole session is then terminated (Supabase: User sessions). So Cause 1 and Cause 2 can turn into this error on the next refresh.
How to fix it
- Ask whether the user signed out in another tab or on another device. A sign-out ends the session for that browser's token.
- Check whether your project sets an inactivity timeout or a timebox for sessions. If it does, a user who returns after that period needs to sign in again.
- If Cause 1 or Cause 2 may have run, fix those first, so the session is not ended again.
- Have the user sign in again to get a new session.
Source: Supabase: Auth error codes, Supabase: User sessions
App broke after you published it? Our AI agent fixes it in your code, then tests your live app again so you see the result yourself. The first check is free. Check my app free
Cause 4: the new refresh token was never saved (Next.js, several clients)
Each refresh returns a new refresh token. If your app does not save it, the next request sends the old one, and Supabase answers "Refresh Token Not Found".
- Next.js proxy (middleware): return the same response object that the Supabase client wrote the cookies to (
supabaseResponsein Supabase's Next.js guide). If the code returns a newNextResponse, the refreshed cookies are dropped. See Supabase: Next.js server-side auth. - One browser client: create the client once and import it everywhere, rather than calling
createClientin each page or component:
// lib/supabase.ts
import { createBrowserClient } from '@supabase/ssr'
export const supabase = createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!
)
- Recover instead of looping: when the session cannot be refreshed, clear it locally and send the user to sign in:
const { error } = await supabase.auth.getSession()
if (error?.code === 'refresh_token_not_found' || error?.code === 'refresh_token_already_used') {
await supabase.auth.signOut({ scope: 'local' })
window.location.href = '/login'
}
How do I check it's fixed?
- Open your live app in a private (incognito) window and sign in with an account you can test with.
- Open the app in two tabs and use both for a few minutes. Neither tab should show "Already Used" or "Refresh Token Not Found".
- Sign out in one tab, then check that the other tab asks you to sign in again without repeating the error.
- Sign in again, refresh the page, and check that you stay signed in.
Steps 2 to 4 are our test plan. The docs do not describe a test procedure.
FAQ
Can I open the app in several tabs without this error?
Yes. Tabs share one session in browser storage, and current supabase-js versions coordinate the refresh between tabs, so each tab does not spend the token on its own. If the error appears with several tabs open, update @supabase/supabase-js to the latest release and make sure the app creates one client, not one per page (Cause 1 and Cause 4).
Why does the error say Already Used when the user signed in only once?
Signing in once does not stop refreshes. The app refreshes in the background, so a timer, the server, and another tab can each try to refresh the same token. The auth-js thread shows a timer that kept an old copy of the token (supabase/auth-js #454).
Can I raise the reuse interval to stop the error?
The docs say the default is 10 seconds and "we do not recommend changing this value" (Supabase: User sessions). Fix the code that refreshes twice instead.
Can VibeFix fix it for me?
Yes, for apps built in Lovable or any app whose code is on GitHub. The free check confirms the problem on your live app first. If you want it fixed, our AI agent finds the cause, fixes it in your code for $79 and tests your live app again. See pricing.
Related guides
- Supabase auth cookie lost after login on Next.js production
- Lovable login loop
- Lovable sign-in works in preview but fails when published
Sources
- [supabase/ssr issue #112: "Error [AuthApiError]: Invalid Refresh Token: Refresh Token Not Found"](https://github.com/supabase/ssr/issues/112) (the exact message as users see it)
- Supabase: User sessions (refresh tokens, reuse interval, session termination)
- Supabase: Auth error codes (refresh_token_already_used, refresh_token_not_found, session_not_found, session_expired)
- Supabase: Next.js server-side auth (setAll, supabaseResponse, getClaims, proxy)
- Supabase: Creating a server-side client (cookies, getSession, getClaims)
- GitHub: supabase/auth-js #454 (stale refresh token in timer, fix in 2.0.0-rc.7)
- GitHub: supabase/supabase-js #805 (Already Used, no maintainer cause given)
Last checked: 16 November 2026
Fixed it? Prove it works on your live app
After the fix, the test that matters is a real sign-in on your live app, with two tabs open and a sign-out in one of them. Your AI fixed it. VibeFix proves it works on the live site.
VibeFix's free check tries the problem you describe on your live app: tell us what broke, and our AI agent tries it and sends you a screenshot. If you want it fixed, it finds the cause, fixes it in your code and re-checks your live app. The free check never changes your app. Check my app free
Our AI agent finds the cause, fixes it in your code for $79, paid up front, and re-checks your live app. If we can't complete your re-check, you get your money back.
VibeFix is independent. Supabase is a trademark of its owner.
Want it fixed?
Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.
It starts with a free check that confirms the problem on your live app, no account needed.
More guides · Shopify store accessibility · About · Your privacy choices