Fix Supabase "42501 permission denied for table" on New Tables (Without Turning Off RLS)

Quick answer: New Supabase table returns 42501 "permission denied for table"? If your project no longer auto-grants Data API access, new public tables need an explicit GRANT. The SQL fix, plus RLS policies, without disabling RLS.

The error

You create a new table (in the SQL editor, a migration, or because Lovable, Bolt, Cursor or another AI tool made it), and your app's first query fails:

{
  "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;"
}

Older tables in the same project still work. Only the new one is broken.

Why it happens

Supabase announced a change to a default. Previously, every new table in the public schema was automatically granted select, insert, update and delete for the anon, authenticated and service_role roles, so the Data API (what supabase-js calls) could reach it immediately.

Per Supabase's changelog, new projects were scheduled to stop getting those automatic grants from May 30, 2026, and the same change was scheduled to be applied to all existing projects on October 30, 2026. As of November 22, 2026, official Data API docs still say existing projects auto-grant new public tables, and Supabase has not confirmed that the October 30 rollout happened. If the change has reached your project, a new table in public is invisible to the Data API until you run an explicit GRANT.

In plain English, there are now two separate locks:

You need both. What did not change: existing tables keep their grants, RLS works the same as before, and apps that only use a direct Postgres connection (psql, an ORM, a server with a connection string) aren't affected.

Fixes

1. Check which grants the table has

Run this in the Supabase SQL editor:

select grantee, privilege_type
from information_schema.role_table_grants
where table_schema = 'public' and table_name = 'your_table';

If anon or authenticated is missing from the list, that's your 42501. Also read the hint in the error: it names the exact role and privilege that's missing.

2. Grant only what each role needs

Make sure the roles can use the schema (normally already true on Supabase):

grant usage on schema public to anon, authenticated;

Private data that only signed-in users touch (most app tables):

grant select, insert, update, delete on table public.your_table to authenticated;
grant select, insert, update, delete on table public.your_table to service_role;

Public read-only data (for example a product list visitors can browse):

grant select on table public.products to anon, authenticated;

Don't grant anon write access unless logged-out visitors truly need to write (for example a public contact form, and then only insert).

3. Turn RLS on and write policies scoped to auth.uid()

A grant opens the door to the whole table, so RLS must decide which rows. For a table with a user_id column:

alter table public.your_table enable row level security;

create policy "Users read own rows" on public.your_table
  for select to authenticated
  using ((select auth.uid()) = user_id);

create policy "Users insert own rows" on public.your_table
  for insert to authenticated
  with check ((select auth.uid()) = user_id);

create policy "Users update own rows" on public.your_table
  for update to authenticated
  using ((select auth.uid()) = user_id)
  with check ((select auth.uid()) = user_id);

create policy "Users delete own rows" on public.your_table
  for delete to authenticated
  using ((select auth.uid()) = user_id);

For public read-only data:

alter table public.products enable row level security;
create policy "Anyone can read products" on public.products
  for select to anon, authenticated
  using (true);

4. Add the GRANT to every future migration

From now on, every create table your AI tool writes needs its grant lines (and RLS policies) in the same migration. Otherwise each new table breaks the same way. Supabase notes this applies however the table was created: SQL editor, migrations, CLI, MCP or an AI coding tool.

5. Don't "fix" it by disabling RLS or using the service role key in the browser

AI agents often "fix" this error by running alter table ... disable row level security, granting everything to anon, or pasting the service_role / secret key into frontend code. The error goes away, but your data becomes readable (and often writable) by anyone who has your public anon key, which every visitor's browser has. Disabling RLS also doesn't fix a missing grant: it's the wrong lock. Keep RLS on, grant the minimum, and write the policies you need.

Prompt to paste into Lovable, Bolt or Cursor

My Supabase query on the "your_table" table fails with error 42501 "permission denied for table". Supabase no longer grants Data API access to new public tables automatically, so this needs an explicit GRANT. First show me the current grants (information_schema.role_table_grants) and RLS policies for this table. Then write one SQL migration that: grants only the privileges the app needs to the authenticated role (and anon only for public read-only data), keeps RLS enabled, and adds select/insert/update/delete policies scoped to (select auth.uid()) = user_id. Do NOT disable RLS, do NOT grant write access to anon, and do NOT put the service_role key in client code. Also add the same grant pattern to any other tables you create from now on.

FAQ

Why do my old tables still work? Existing tables keep the grants they already had. The change only affects tables created after it reached your project.

I added an RLS policy but still get 42501. Why? Policies don't help if the role has no GRANT on the table. Check the grants first (step 1). If the grant exists and inserts still fail with "new row violates row-level security policy", that's the policy side: see our empty data / RLS guide.

Is granting to anon dangerous? Only without RLS. A grant lets the role reach the table, and RLS limits the rows. Grant anon only what logged-out visitors need, usually select on public data.

Can I just turn the old behavior back on? Supabase's docs still describe an "Automatically expose new tables" setting in the Data API settings, and the CLI auto_expose_new_tables flag is still present — the planned October 30, 2026 removal was withdrawn in CLI v2.116.0. Explicit grants are the durable fix either way.

Does this affect my server that connects with a connection string? No. Per Supabase, direct Postgres connections aren't affected; it's the Data API (supabase-js, REST, GraphQL) that needs the grants.

Related guides

Still stuck? Paste your exact error into the free Error Fixer to get a plain-English cause, the fix, and a prompt to paste back into your AI tool.

Fix it faster

Best for this error

Supabase 42501 + RLS Fix Kit

Copy-paste GRANT + RLS SQL, a diagnosis flowchart, 10 AI prompts for Lovable, Bolt, Cursor and v0, and a pre-launch security checklist. Never turns RLS off.

$7

Buy now

Secure checkout via Payhip (PayPal or card)

The Fix Pack: top 50 errors, explained

18-page PDF with causes, step-by-step fixes and AI prompts for the 50 most common vibe-coding errors.

$9

Buy now

Secure checkout via Payhip (PayPal or card)

Get the free "10 Prompts That Fix Broken AI Code" pack

Join the UnbreakKit newsletter: one short email a week with real errors from Cursor, Lovable, Bolt & Replit users and how to fix them. Unsubscribe anytime.

Newsletter signup powered by beehiiv. We only use your email to send the newsletter.