VibeFix

Guide · Supabase

Supabase "permission denied for table" (42501): how to fix it

Still failing on your live site? Check it free ↓

Published by Yosef Dabian, founder of VibeFix

Updated

Short answer: Supabase returns "permission denied for table" (code 42501) when the role your app uses through the API has no GRANT on that table. Since 30 October 2026 Supabase no longer grants API access to new tables in the public schema in existing projects, so add the GRANT, turn on row level security and add policies in the same step.

Key takeaways

To get this SQL filled in with your table name, use our free Supabase 42501 GRANT SQL generator: it turns on row level security, then adds the grants and Supabase's example policy.

Do not fix it with a bare grant select ... to anon on a table whose row level security is off: anyone with your publishable (anon) key could then read every row, and that key is in your app's front end.

Fixed in your code, then tested live. Did the steps and it still fails? Our AI agent finds why on your live app with a free check, usually in under 10 minutes, then can fix it in your code.

Free. No account needed. It usually takes under 10 minutes.

Want it fixed? For Lovable apps or code on GitHub, our AI agent fixes it in your code for $29 and tests your live app again. If we can't complete your re-check, you get your money back.

What does Supabase "permission denied for table" (42501) mean, and what fixes it?

It means Postgres refused the request because the role lacked a privilege: 42501 is the standard code insufficient_privilege (PostgreSQL error codes). Which fix applies depends on what you see: a missing GRANT on a recently created table, row level security blocking a write, a schema you created yourself, the auth or vault schema, restricted columns, or missing access to a sequence.

Why did my new table start returning "permission denied for table" (42501)?

Supabase applied a change to all existing projects on 30 October 2026, so new tables in the public schema are not reachable through the Data API until access is granted.

Supabase announced on 28 April 2026 that new tables in the public schema are not reachable through the Data API until access is granted. It became the default for new projects from 30 May 2026, rolled out over a few weeks, and was applied to all existing projects on 30 October 2026. Tables you already have keep their current grants and stay reachable; the change hits tables created after it (Supabase changelog).

Before the change, every new table in public was granted to the anon, authenticated and service_role roles automatically. That is why an older table works and the one your AI tool just created does not.

The error your app gets back has code 42501 and the message permission denied for table your_table, with a hint that names the missing role and privilege and shows the GRANT statement to run, for example one for anon.

Is the GRANT in the 42501 hint enough to fix it?

No: the hint names the missing GRANT but does not check row level security, so the grants, enabling row level security and the policies belong in the same migration.

Grants decide whether a role can reach a table; row level security decides which rows. Supabase's advice is to treat three things as one unit, in the same migration: the grants, enabling row level security, and the policies (Supabase changelog).

How do I fix "permission denied for table" safely, role by role?

Turn on row level security, grant the roles you need on the table, and add policies so each signed-in user reads and changes only their own rows.

Run these in the SQL Editor of your project, or put them in the migration that creates the table. Replace your_table and user_id with your table and its owner column.

  1. Turn on row level security first: alter table public.your_table enable row level security;
  2. Signed-in users (the authenticated role): grant select, insert, update, delete on public.your_table to authenticated;
  3. Your server code (the service_role role): grant select, insert, update, delete on public.your_table to service_role;
  4. Signed-out visitors (the anon role), only if they really need to read this table: grant select on public.your_table to anon; and add a select policy to anon, or signed-out visitors still get an empty list. Most private tables should not get this line.
  5. Let each signed-in user read only their own rows: create policy "own rows: read" on public.your_table for select to authenticated using ((select auth.uid()) = user_id);
  6. Let them add only their own rows: create policy "own rows: insert" on public.your_table for insert to authenticated with check ((select auth.uid()) = user_id);
  7. Let them change only their own rows: create policy "own rows: update" on public.your_table for update to authenticated using ((select auth.uid()) = user_id) with check ((select auth.uid()) = user_id);
  8. Let them delete only their own rows: create policy "own rows: delete" on public.your_table for delete to authenticated using ((select auth.uid()) = user_id);
  9. If the table has an auto-numbered id: grant usage, select on all sequences in schema public to authenticated, service_role;

If you use migrations, keep these in the same migration that creates the table, so the next new table does not break the same way. More on roles and grants: Supabase: securing your API.

How do I check which roles can reach the table?

Query the table's grants and which public tables have row level security off, or look at the Data API exposure badge in the Table Editor.

How do I check that the data is hidden while signed out?

Call the table with only the publishable (anon) key and no sign-in token, on a table that has rows in it. Use the same key your app's front end uses. For example, call https://YOUR-PROJECT.supabase.co/rest/v1/your_table?select=*&limit=5 with the header apikey: YOUR_PUBLISHABLE_KEY.

Then sign in as one test user in your app and confirm you see your own rows and not another user's.

How do I check it's fixed?

Repeat the action that failed, on your live app, as a person who has never used it.

  1. Open your live app in a private (incognito) window.
  2. Sign up with a brand-new email address, or sign in as a test user who is not you.
  3. Do the thing that failed before: save, add or list the data on the new table.
  4. Check that it saves and that the data is still there after a page refresh.
  5. Sign up a second new test user and check they cannot see the first user's rows.

Why do my older tables work while a new table fails with 42501?

Tables you made earlier keep their access, while a table added after the change fails until it gets its grant. So the pages you use most keep working, and a table your AI tool just created does not.

New tables in public need explicit grants before the Data API can reach them

Supabase's changelog describes a change that applies to existing projects from 30 October 2026: a new table in the public schema is not reachable through the Data API until it has an explicit grant. That is why a table your AI agent or builder just created can return permission denied for table (42501) while older tables still work.

  1. Add the grants in the same migration that creates the table, for the roles your app uses: grant select, insert, update, delete on public.your_table to authenticated;
  2. Turn on row level security in the same migration: alter table public.your_table enable row level security;
  3. Add a policy so each signed-in user reads and changes only their own rows.
  4. Grant select to anon only if the table is meant to be public, and only after the policies are in place.
  5. Run the SQL in the SQL Editor, or as part of your migration, then load the page again while signed in.
  6. To fill in your table name and get the SQL, use the 42501 GRANT SQL generator.

Frequently asked questions

Why did 42501 start after 30 October 2026?

Supabase applied a change to all existing projects on 30 October 2026: new tables in the public schema are no longer reachable through the Data API until you grant access. Tables you already had keep their grants.

Will my old tables break?

No. Existing tables keep their current grants and stay reachable. Only tables created after the change need explicit grants.

Should I just run grant select to anon?

Only if signed-out visitors really need to read that table, and only with row level security turned on and a policy in place. With row level security off, the anon grant lets anyone with your publishable key read every row.

Is 42501 a row level security error?

It can be either. A missing grant gives 42501 before any policy runs. Row level security also returns 42501 when it blocks an insert or update. Check the grants first, then the policies.

Does this affect tables an AI builder creates for me?

Yes, the same way. A table created by an AI builder, a script or a migration after the change needs its grants, row level security and policies like any other new table.

Where can I see which tables are exposed?

The Data API exposure badge in the Table Editor of your Supabase dashboard shows which tables are exposed. Before 30 October the Security Advisor also flagged affected tables.

Can VibeFix fix it for me?

Yes, for any app whose code is on GitHub, whichever tool built it (Lovable, Bolt, Base44, Replit, v0, Cursor). The free check confirms the problem on your live app first. If you want it fixed, our AI agent finds the cause, fixes it in your code for $29 and tests your live app again. See pricing.

Related guides

Sources (official documentation)

Still broken?

If the error is gone but your live app still breaks for new users, start with a free check: our AI agent tries your live app like a new user and shows you what breaks. Then, on request, it reviews your code independently, because VibeFix is independent of every app builder. It fixes it in your code and re-checks your live app. The free check signs up once as "VibeFix Test" with its own inbox, needs no account, never changes your app and never emails your users. Today the fix is for apps built with Lovable, or any app whose code is on GitHub.

Related: Supabase RLS policy generator · Fix 42501 tool · Data won't save: "new row violates row-level security policy" · Edits or upserts blocked by row-level security · Users can see other users' data in my Lovable app · "Database error saving new user" · ShipFix alternatives: services that fix a vibe-coded app

VibeFix is independent. Lovable, Bolt, Replit, Base44, v0, Supabase, Firebase, Stripe and Vercel are trademarks of their owners.

Want it fixed for you? For any app whose code is on GitHub, whichever tool built it, VibeFix's AI agent can find the cause of this error, fix it in your code and re-check your live app. Start with a free check: https://vibe-fixer.com

Still seeing this error? Get it fixed, starting with a free check ↑

How this guide was made: Written with AI assistance and checked against the sources linked on this page.

More guides · Videos · Use VibeFix in Claude Code · Shopify store accessibility · About · Your privacy choices