permission denied for table (Supabase error 42501)
On this page
Short answer
The role making the request (anon or authenticated) has no grant on the table, and Postgres checks grants before any RLS policy runs. Supabase scheduled this for all existing projects on 30 October 2026: once it reaches your project, new tables in public get no automatic grants. Add the grant from the error's hint, keep RLS on, and add policies.
Find a fix pack
Checklists and prompts for Supabase security, Stripe payments and deploys. Each pack is $24, or $49 for all three.
The exact error you'll see
In the network response JSON from the Data API (PostgREST), for example in the browser's Network tab:
{
"code": "42501",
"message": "permission denied for table your_table",
"hint": "Grant the required privileges to the current role with: GRANT SELECT ON public.your_table TO anon;"
}
Your table name, role and privilege replace your_table, anon and SELECT. Supabase notes 42501 errors are "often reported by clients as 401 or 403 errors."
Applies to
- Supabase projects called through the Data API:
supabase-js, other client libraries, PostgREST, GraphQL, or direct HTTP to/rest/v1/or/graphql/v1 - Tables in the
publicschema, especially ones created by an AI tool, migration or script withoutGRANTstatements - The Automatically expose new tables setting under Integrations > Data API
- Not affected: direct Postgres connections (psql, ORMs, connection strings); tables in
storage,auth,realtimeand custom schemas
Why it happens
- New default. Supabase's timeline: opt-in at project creation from 28 April 2026, default for new projects from 30 May 2026, and applied to all existing projects on 30 October 2026. After that, new
publictables "require an explicit opt-in" through a Postgresgrant. Existing tables keep their grants. - Grants come first. "If the grant is missing, Postgres rejects the query before RLS comes into play."
- Column restrictions. Column-level privileges cause 42501 on restricted columns, "This includes using
select *." - Protected schemas. API roles can't reach
authorvault.
If you built the app in Lovable on its built-in backend: since 12 November 2026, when you publish a project that has unresolved critical security findings, Lovable asks you to review them first. You can open them in the Security view, publish anyway, or ask Lovable to fix them all in one request, which uses one of your free fixes. This prompt is not a lock, and it does not replace Row Level Security policies. Source: Lovable changelog, 12 Nov 2026, https://docs.lovable.dev/changelog (opens in a new tab)
How to fix it, step by step
- Read the
hint. It names the role and privilege that failed. - Check current grants in the SQL Editor:
select grantee, privilege_type
from information_schema.role_table_grants
where table_name = 'your_table';
Source: https:/
- Grant only what each role needs, enable RLS and add a policy in the same migration. This is Supabase's own pattern:
grant select on public.your_table to anon;
grant select, insert, update, delete on public.your_table to authenticated;
alter table public.your_table enable row level security;
create policy "users can read their own rows"
on public.your_table
for select
to authenticated
using (auth.uid() = user_id);
Change user_id to your owner column. Many tables need no anon grant at all.
- If an AI tool creates your tables, tell it to put the
GRANT,enable row level securityandcreate policystatements in every table-creating migration. Supabase suggests updating the tool's system prompt. - Don't disable RLS to clear the error. RLS isn't what's failing.
What the docs don't spell out
- Grants without RLS expose the whole table. Supabase says a table in an exposed schema without RLS "is readable and writable by any role with a grant on it." Run the grant and the RLS steps together. (RLS guide (opens in a new tab))
- After the grant, 42501 can still come from RLS. Supabase says that if
anonorauthenticatedtries to UPDATE or INSERT "without the necessary RLS permissions, Postgres will return a 42501 error." Fixed the grant and still getting 42501 on a write? Check your policy next. (Supabase KB (opens in a new tab)) - Sequences have defaults too. Supabase's default-privileges table lists
usage,select,updateon new sequences, and its rollback SQL re-grantsusage, select on sequencesalongside tables. (Securing your API (opens in a new tab), changelog (opens in a new tab))
How to check it worked
- Re-run the grants query. Each role your app uses should list the privileges it needs.
- The request returns rows, or an empty list if no policy matches.
- The Table Editor's Data API exposure badge and Security Advisor list tables worth reviewing.
Sources
- https:/
/ : dates, error JSON, grant/RLS/policy SQL, affected and unaffected cases, sequence rollbacksupabase. com/ changelog/ 45329- breaking- change- tables- not- exposed- to- data- and- graphql- api- automatically (opens in a new tab) - https:/
/ : 401/403 reporting, grants query, Integrations > Data API, column restrictions, RLS 42501, forbidden schemassupabase. com/ docs/ guides/ troubleshooting/ database- api- 42501- errors (opens in a new tab) - https:/
/ : default privileges table, Automatically expose new tablessupabase. com/ docs/ guides/ api/ securing- your- api (opens in a new tab) - https:/
/ : grants checked before policies, no-RLS exposuresupabase. com/ docs/ guides/ database/ postgres/ row- level- security (opens in a new tab)
Related fixes
Tool to consider: Supabase.
Find a fix pack
Checklists and prompts for Supabase security, Stripe payments and deploys. Each pack is $24, or $49 for all three.