Invalid Refresh Token: Refresh Token Not Found
Last verified:
The fix
Supabase rejected the refresh token in the cookie. It was already rotated or revoked, or the new token was never written back onto the response.
- 1
Stop retrying the dead token
When the message is
Refresh Token Not Found, another refresh with the same cookie will fail again and can revoke the session family. Do not loopgetSession()orrefreshSession()in the client. Sign the user out of this browser and send them through sign-in once. IfsignOutitself returns this error, the token is already gone. Clear the site cookies and sign in. - 2
Refresh once, in proxy, with one client
Use
createBrowserClientfrom@supabase/ssrin client components andcreateServerClienton the server. Do not also constructcreateClientfrom@supabase/supabase-jsin the browser for the same project. On Next.js 16, exportproxyfromproxy.ts. On older Next.js, exportmiddlewarefrommiddleware.ts. CallgetUser(), write every cookie fromsetAllonto the response, and return that response. Do not callgetUser()again in an API route on the same request after proxy already refreshed.import { createServerClient } from '@supabase/ssr' import { NextResponse } from 'next/server' export async function proxy(request) { let supabaseResponse = NextResponse.next({ request }) const supabase = createServerClient( process.env.NEXT_PUBLIC_SUPABASE_URL, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY, { cookies: { getAll() { return request.cookies.getAll() }, setAll(cookiesToSet) { cookiesToSet.forEach(({ name, value }) => request.cookies.set(name, value)) supabaseResponse = NextResponse.next({ request }) cookiesToSet.forEach(({ name, value, options }) => supabaseResponse.cookies.set(name, value, options), ) }, }, }, ) await supabase.auth.getUser() return supabaseResponse } - 3
Sign out of this session only
A button that calls
signOut()with no arguments revokes every session. Use local scope so other devices keep their refresh tokens. After the call, thesb-auth cookies for this host should be gone. If a second tab still has the old cookie, that tab will throw this error once. Reload it and sign in. Do not switch the server to the service role key to skip the refresh.await supabase.auth.signOut({ scope: 'local' }) - 4
Clear a stuck cookie once, then upgrade the package
In the browser devtools, delete cookies for localhost and the deployed host whose names start with
sb-. Sign in again. If the project is on@supabase/ssrolder than 0.8.1, upgrade it so the server client does not refresh in the background before yourgetUser()call. On a self-hosted Auth server, setGOTRUE_SECURITY_REFRESH_TOKEN_REUSE_INTERVALto a few seconds. Do not disable refresh-token reuse detection.
Why it happens
The browser or the server log shows AuthApiError: Invalid Refresh Token: Refresh Token Not Found. Auth is saying the refresh token on this request is not a live token for a session.
Supabase's session guide: a refresh token is used once, with two exceptions. It can be presented again inside a reuse interval. The docs say that interval defaults to 10 seconds and they do not recommend changing it. And if you present the parent of the token that is current now, the server returns the current pair instead of ending the session. That second case is a lost response: the server rotated the token, and the browser never stored the new Set-Cookie. Outside those two cases, reuse revokes the whole session.
The cookie is stale when something else already rotated or revoked it. Two clients do that with one token. A browser tab and the server proxy both refresh, or createClient from @supabase/supabase-js (local storage) sits next to createBrowserClient from @supabase/ssr (cookies). @supabase/ssr also used to refresh in the background while your own getUser() refreshed. The package maintainers fixed that in @supabase/ssr 0.8.1 by skipping auto-initialize on the server client. Upgrade if you are older than that.
The other miss in generated Next.js apps is the proxy. getUser() refreshes when the access token is near expiry, and the new refresh token has to be copied onto the outgoing response with setAll. Drop that response and the browser keeps the old token. The next call is Refresh Token Not Found. On Next.js 16 the refresh is proxy.ts exporting proxy. On older Next.js it is middleware.ts exporting middleware. A missing session with no refresh-token error is the page for auth session missing after refresh.
supabase.auth.signOut() with no scope defaults to global. Supabase's server-side guide says that revokes the refresh token for every session that user has, including other tabs and a server cookie that still holds the old token. Those tabs then throw this error. End this session with { scope: 'local' }.
Self-hosted GoTrue can have the reuse interval off. The @supabase/ssr maintainers say to set GOTRUE_SECURITY_REFRESH_TOKEN_REUSE_INTERVAL to a few seconds on a self-hosted project. Hosted projects already have a short window. Do not turn reuse detection off to hide a dead cookie.
The next error you'll probably hit
Once this is fixed, the usual follow-up is Auth session missing after refresh. Auth session missing: sign-in worked in the browser, but Next.js cannot see the Supabase cookie. Use the @supabase/ssr server client and refresh.
Prompt to paste back into your AI tool
Paste this above the error.
Supabase throws AuthApiError: Invalid Refresh Token: Refresh Token Not Found. It happens on <where: server log, browser, or both>.
Do not disable refresh-token reuse detection. Do not switch the server to the service role key. Do not call refreshSession in a loop. Do not create a second Supabase client with @supabase/supabase-js next to @supabase/ssr.
1. Show me every createClient / createBrowserClient / createServerClient in this app.
2. Refresh the session in one place: proxy.ts exporting proxy on Next.js 16, or middleware.ts exporting middleware on older Next. Call getUser() and return the response that setAll wrote cookies onto.
3. Change sign-out to supabase.auth.signOut({ scope: 'local' }).
4. Tell me to delete the sb- cookies once and sign in again. Do not rewrite unrelated pages.Common questions
+getSession() still shows a user and getUser() throws this. Which one do I trust?
getUser(). getSession() reads the cookie and does not prove the refresh token is still valid. When getUser() returns Refresh Token Not Found, that cookie is dead. Clear it and sign in again.
+Signing out on my laptop broke the phone session. Why?
signOut() with no scope is global. It revokes every refresh token for that user, so the other device sends a token Auth has already revoked. Use signOut({ scope: 'local' }) when you only mean this browser.
Related errors
- Auth session missing after refreshAuth session missing: sign-in worked in the browser, but Next.js cannot see the Supabase cookie. Use the @supabase/ssr server client and refresh.CursorLovableBoltSupabaseAuthOct 14, 2026
- JWT expiredJWT expired. PostgREST code PGRST301. The access token on this request is past its exp. Let the client refresh the session. A dead refresh token is a different error.CursorLovableBoltSupabaseAuthOct 27, 2026
- ERR_TOO_MANY_REDIRECTS on loginERR_TOO_MANY_REDIRECTS on login means the guard and the login page redirect to each other. Exclude the sign-in route and read the session from one place.Cursorv0BoltAuthNext.jsOct 14, 2026
- Error 400: redirect_uri_mismatchGoogle rejected the OAuth request because the redirect_uri it received is not one of the Authorized redirect URIs on that OAuth client. The deployed domain and the callback URL are different strings.CursorLovableBoltAuthSupabaseNov 11, 2026
- The "middleware" file convention is deprecated. Please use "proxy" instead.Next.js 16 still runs middleware.ts and prints this warning. The file is now proxy.ts, the export is proxy, and the runtime is Node.js.Cursorv0BoltNext.jsAuthOct 23, 2026