Supabase 'Invalid Refresh Token: Refresh Token Not Found'
Workaround available Web (Next.js, SSR frameworks) Updated October 21, 2026
Quick answer
Refresh tokens are single-use; if middleware refreshes the session but doesn't write the new cookie back, the next request uses a dead token. Return the response object your cookie setAll modified.
Most likely fix: Return the same response from middleware.
Symptoms
Users are logged out randomly (often daily), server logs show AuthApiError 'Invalid Refresh Token: Refresh Token Not Found' or 'AuthSessionMissingError: Auth session missing!'.
Why it happens
- Next.js middleware refreshes the session but returns a different response without the new cookies
- Route handler creates its own client without reading request cookies
- Session revoked or expired after long inactivity
- Local storage/cookies cleared
How to fix it
Try these in order — the most common fix is first.
1. Return the same response from middleware
- Use createServerClient from @supabase/ssr in middleware
- In cookies.setAll write cookies to the response object
- Return exactly that response object
2. Use a cookie-aware client in route handlers
- Create createServerClient with await cookies() inside the handler
- Make sure the middleware matcher covers the route
3. Use getUser() on the server
- Call supabase.auth.getUser() rather than trusting getSession() server-side
4. Sign the user out cleanly on this error
- Catch the error, call supabase.auth.signOut() and redirect to login
This guide also covers
- invalid refresh token refresh token not found supabase
- supabase auth session missing
- supabase user logged out randomly
- supabase nextjs session not persisting
Still not working?
If Supabase keeps failing, you're not alone. See every Supabase problem users report or the alternatives people switch to.
Other Supabase errors
- Supabase Project Paused
- Supabase Max Client Connections Reached
- Supabase 'New Row Violates Row-Level Security Policy' Error
- Supabase Confirmation Email Not Sending
- Supabase Auth Redirects to Localhost
- Supabase Edge Function 546 WORKER_LIMIT Error
- Supabase Storage Upload Failed
- Supabase 'Canceling Statement Due to Statement Timeout'
- Supabase Realtime Not Working
- Supabase Database Connection 'Network Is Unreachable'
- Supabase Start Not Working (Docker Container Unhealthy)