AuthSessionMissingError: Auth session missing!
Supabase · updated 2026-11-23
Returned by supabase-js when an auth call needs a signed-in user and the client has no session: getUser() with no access token in storage, and updateUser(), setSession() or refreshSession() without one. It is also what you get when the auth server answers session_not_found because the user signed out elsewhere or was deleted, and getUser() then clears the local session. By default it comes back in the error field with status 400, not thrown. Most reports are from server code (Next.js Server Components, Route Handlers, middleware) whose client can't see the browser's auth cookies.
AuthSessionMissingError: Auth session missing!
at node_modules/@supabase/auth-js/dist/main/GoTrueClient.js:2715:59
at SupabaseAuthClient._useSession (node_modules/@supabase/auth-js/dist/main/GoTrueClient.js:2502:26)
at async SupabaseAuthClient._getUser (node_modules/@supabase/auth-js/dist/main/GoTrueClient.js:2707:20)
at async SupabaseAuthClient.getUser (node_modules/@supabase/auth-js/dist/main/GoTrueClient.js:2691:22) {
__isAuthError: true,
status: 400,
code: undefined
}Quick fix
Treat it as "not signed in", not as a crash: check isAuthSessionMissingError(error) and redirect to sign in or render the signed-out page. If the user is signed in and you still get it on the server, the server client isn't reading the auth cookies: create it with createServerClient from @supabase/ssr and pass cookies getAll and setAll, and refresh the session in middleware (proxy) so Server Components get a valid cookie. To check who is signed in on the server, Supabase now recommends getClaims(), which verifies the token and returns data: null with no error when there is no session.
- Check what you got: error.name is AuthSessionMissingError (or isAuthSessionMissingError(error) is true) and data.user is null. Nothing broke; the client has no session.
- In the browser: was anyone signed in? A page that loads before sign-in, or after signOut() in another tab, gets this on every getUser().
- On the server: log the request's cookie names. No sb-<project-ref>-auth-token cookie means the browser never sent it (a fetch from another origin without credentials, or a cookie set for a different domain).
- If the cookie is there, the client is wrong: a plain createClient() on the server has no access to cookies. Use createServerClient from @supabase/ssr with cookies.getAll and cookies.setAll.
- Add the middleware (proxy in Next.js 16) from Supabase's Next.js guide that calls getClaims() on each request, so expired tokens are refreshed and written back as cookies. Server Components can't set cookies themselves.
- Branch on the error instead of throwing it, so a signed-out visitor sees the sign-in page rather than an error page.
import { isAuthSessionMissingError } from '@supabase/supabase-js';
const { data, error } = await supabase.auth.getUser();
if (isAuthSessionMissingError(error)) {
// No session: a signed-out visitor, or a server client that can't see the cookies
redirect('/login');
}
if (error) throw error; // anything else is a real failure: report it
const user = data.user;
// On the server, getClaims() says "nobody" without an error:
// const { data: claims } = await supabase.auth.getClaims(); // claims is null when signed outPaste this into Claude Code, Cursor or Codex in the project that throws it. The agent reads this guide in plain text and applies the fix that matches your stack.
Read https://runheed.com/errors/supabase-auth-session-missing.md and fix this error in this project.Why it happens
Nobody is signed in
getUser() on a page a signed-out visitor can open returns this every time. It is the normal answer for "no user", so code that throws any error from getUser() turns every anonymous visit into a 500.
Server client without cookies
In Next.js, SvelteKit or Remix the session lives in cookies. A client made with createClient() on the server has no storage and no session, so getUser() reports it missing even for a signed-in user. createServerClient from @supabase/ssr with getAll and setAll fixes it.
No middleware refreshing the session
Access tokens expire. Server Components can read cookies but not write them, so without the middleware (proxy) that refreshes the token on each request, a long-lived tab ends up with no usable session on the server.
The cookie never arrived
A fetch to your API from another origin without credentials: include, an API on a different domain than the cookie, or a mobile or server-to-server call that sends no cookie or Authorization header.
Signed out somewhere else
The access token is still in storage but the auth server answers session_not_found: the user signed out on another device, an admin deleted the user or ended the session. supabase-js maps that to AuthSessionMissingError and getUser() clears the local session.
Other fixes
- Calling updateUser() or setSession() before the session has loaded gives the same error. In the browser, wait for onAuthStateChange to report INITIAL_SESSION before calling them.
- Passing a JWT yourself (getUser(jwt)) skips the stored session, so an API that receives a bearer token can check it without cookies.
- Don't trust getSession() on the server to decide who someone is: it reads the cookie without checking it. Supabase recommends getClaims() there.
- Report the errors that are not AuthSessionMissingError yourself: supabase-js returns auth errors instead of throwing them, so a global error handler never sees them.
Same error, other wording
- Auth session missing!
- AuthSessionMissingError
- {"name":"AuthSessionMissingError","message":"Auth session missing!","status":400}
Let your coding agent catch the next one
supabase-js returns this in the error field instead of throwing it, so unless your code throws it or reports it Runheed doesn't record it. What it does record is the exceptions your running server code throws (route handlers, server rendering, API errors and background jobs) with the stack trace and the breadcrumbs before them, and serves those errors to Claude Code, Cursor or any MCP client.
Setup for Supabase Edge Functions or Node.js and Express, then have your agent fix and resolve it.
Related errors
- TokenExpiredError: jwt expired
- error: new row violates row-level security policy for table "todos"
- FunctionsHttpError: Edge Function returned a non-2xx status code
More in Network and HTTP
- Error: read ECONNRESETNode.js
- Error: connect ECONNREFUSED 127.0.0.1:5432Node.js
- Error: connect ETIMEDOUT 10.0.4.12:5432Node.js
- TypeError: fetch failedNode.js
- Error: self-signed certificate in certificate chainNode.js
- Error: getaddrinfo ENOTFOUND api.example.comNode.js
- Error: write EPIPENode.js
- Access to fetch at 'https://api.example.com/orders' from origin 'https://app.example.com'...Node.js
- AxiosError: Request failed with status code 401Node.js
- requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.example.com'...Python
- httpx.ReadTimeout: The read operation timed outPython
- ConnectionResetError: [Errno 104] Connection reset by peerPython
- BrokenPipeError: [Errno 32] Broken pipePython
- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer...Python
- Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the clientNode.js
- 422 Unprocessable Entity: {"detail":[{"type":"missing","loc":["body","email"],"msg":"Field...Python
- No signatures found matching the expected signature for payload. Are you passing the raw...Node.js
- Error: 429 You exceeded your current quota, please check your plan and billing details.Node.js
Other error topics
- error: permission denied for table profilesDatabases
- pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection...Databases
- psycopg2.OperationalError: server closed the connection unexpectedlyDatabases
- TypeError: 'module' object is not callableImports and modules
- Error: Cannot find module 'x'Imports and modules
- ImportError: cannot import name 'x' from partially initialized module 'y' (most likely...Imports and modules
- You're importing a module that depends on `useState` into a React Server Component...React and Next.js rendering
- An error occurred in the Server Components render. The specific message is omitted in...React and Next.js rendering
- Error: NextRouter was not mounted.React and Next.js rendering
- panic: runtime error: invalid memory address or nil pointer dereferenceUndefined, None and type errors
- ReferenceError: x is not definedUndefined, None and type errors
- ValueError: invalid literal for int() with base 10: ''Undefined, None and type errors
- pydantic_core._pydantic_core.ValidationError: 1 validation error for User email Field...JSON, parsing and validation
- SyntaxError: Unexpected end of JSON inputJSON, parsing and validation
- RangeError: Invalid time valueJSON, parsing and validation
- Error: error:0308010C:digital envelope routines::unsupportedMemory, async and the process
- CredentialsProviderError: Could not load credentials from any providersMemory, async and the process
- RecursionError: maximum recursion depth exceededMemory, async and the process
- McpError: MCP error -32000: Connection closedMCP servers and clients
- Error: spawn npx ENOENTMCP servers and clients
- ModuleNotFoundError: No module named 'mcp.server.fastmcp'MCP servers and clients
Free tools: Source map stack trace decoder · Uptime and SLA downtime calculator · Error budget calculator · Stack trace formatter · JSON log viewer · HTTP status code reference.
References: Supabase docs: server-side auth for Next.js (createServerClient, cookies, middleware, getClaims), Supabase docs: auth.getUser(), supabase-js source: AuthSessionMissingError and isAuthSessionMissingError, supabase-js source: getUser() returning the error when there is no session, supabase-js source: session_not_found mapped to AuthSessionMissingError
Spotted a mistake? Email hello@greatwork.company. About Runheed.