Supabase Error PGRST301: Invalid or Undecodable JWT

Supabase error PGRST301 (Invalid or Undecodable JWT) explained: what it means, why it happens, and how to fix it — with copy-paste code examples.

Error code PGRST301 Supabase Last verified 2026-08-19

Quick Answer

Always send Authorization: Bearer <anon|service_role|user-jwt>. If that does not apply, regenerate or re-copy keys from Dashboard when they were rotated — the full checklist is below.

Error Code

Error code: PGRST301
Official name: Invalid or Undecodable JWT
Service: Supabase

What does this error mean?

Provided JWT couldn't be decoded or it is invalid.

Common Causes

How to Fix

  1. Always send Authorization: Bearer <anon|service_role|user-jwt>
  2. Regenerate or re-copy keys from Dashboard when they were rotated
  3. Use supabase.auth.getSession() to attach the current access token
  4. Never expose the service_role key to the client

Code Examples

Server-side authenticated request javascript
fetch('https://<project>.supabase.co/rest/v1/todos', {
  headers: {
    apikey: anonKey,
    Authorization: `Bearer ${accessToken}`, // never service_role client-side
  },
})

The Authorization header must carry a JWT the project's secret can verify.

Framework-Specific Fixes

supabase-js

The client attaches the JWT automatically; a PGRST301 usually means the session is stale - refresh first.

const { data: { session } } = await supabase.auth.getSession()
if (!session) {
  await supabase.auth.signInWithPassword({ email, password })
}
const { error } = await supabase.from('todos').select('*')
if (error?.code === 'PGRST301') {
  // token invalid - force re-authentication
  await supabase.auth.signOut()
}

You Might Also Like

Frequently Asked Questions

Why am I seeing Supabase error PGRST301?

Most often this happens when missing or malformed Authorization: Bearer header, or when anon key used after the project's JWT secret was rotated.

How do I fix Supabase error PGRST301?

Always send Authorization: Bearer <anon|service_role|user-jwt>.

Which frameworks have documented fixes for error PGRST301?

This page documents fixes for: supabase-js.

Official Sources

This page is based on the official Supabase documentation linked below and adds practical troubleshooting guidance on top.