Supabase says "permission denied for table" (42501). Here's the fix that doesn't open your data to everyone.
Last reviewed October 29, 2026 against the providers' current documentation.
The short version
Error 42501 means the database role your app used isn't allowed to do that. permission denied for table your_table means the role has no grant on the table at all. From October 30, 2026 that's how every new table in public starts on existing Supabase projects. Fix it by granting only the operations your app needs, to the roles that need them, with RLS on and a policy per operation: the generator below writes that SQL for your table. new row violates row-level security policy is the other 42501: the grant is fine, but no policy allows that row. Fix the policy, never turn RLS off.
Write the SQL for your table
Fill in your table, pick who uses it, and copy the migration into the Supabase SQL editor. Runs in your browser; nothing is sent anywhere.
-- Turn on JavaScript to build the SQL here, or copy the example in step 3.Why it matters
The quick fixes for a 42501 all make the error go away by opening the table: granting everything to anon, turning Row Level Security off, putting the service_role key in the browser, or restoring Supabase's old default privileges. Your app's publishable or anon key sits in its public JavaScript, so a table that anon can reach without RLS can be read and changed by anyone who opens your site. AI coding tools reach for these fixes first because they work immediately.
Fix it, in this order
Read which 42501 you have
Look at the error'smessage. permission denied for table your_table is a missing grant; the Data API returns it with ahintsuch asGRANT SELECT ON public.your_table TO anon;. new row violates row-level security policy for table "your_table" is a policy problem: jump to step 5. If the hint namesanonbut your users are signed in when it happens, the request went out without the user's session; fix that in the app instead of granting toanon.Decide who should reach the table
Answer two questions per table: do signed-out visitors need to read it (a public price list, blog posts), or only signed-in users? And does each user only work with their own rows? Most app tables are signed-in users with their own rows. Only grant toanonfor data you'd be happy to see on your home page.Grant, turn on RLS and add policies in one migration
Use the generator above, or adapt this for signed-in users who manage their own rows:
Leave out the operations your app doesn't do. If your own server code uses thegrant select, insert, update, delete on public.your_table to authenticated; alter table public.your_table enable row level security; create policy "Owners read" on public.your_table for select to authenticated using ( (select auth.uid()) = user_id ); create policy "Owners add" on public.your_table for insert to authenticated with check ( (select auth.uid()) = user_id ); create policy "Owners edit" on public.your_table for update to authenticated using ( (select auth.uid()) = user_id ) with check ( (select auth.uid()) = user_id ); create policy "Owners delete" on public.your_table for delete to authenticated using ( (select auth.uid()) = user_id );service_roleor a secret key on this table, it needs a grant too (grant select, insert, update, delete on public.your_table to service_role;); that key bypasses RLS, so it stays on the server.If the error names a sequence
permission denied for sequence your_table_id_seq comes from an id column filled by a sequence. Grant the role that inserts the right to use it:grant usage, select on sequence public.your_table_id_seq to authenticated;. Supabase's opt-in SQL stops granting new sequences by default together with new tables.Fix "new row violates row-level security policy"
The role has the grant, but no policy lets this row through. For an insert, thewith checkcondition failed: usuallyuser_idwasn't set to the signed-in user. Send it from the app or give the columndefault auth.uid(). An update needs aselectpolicy as well as theupdatepolicy, or it won't work as expected. Never fix it by disabling RLS or with a policy ofusing (true)on writes.Test as a stranger and as another user
Open the app in a private window without logging in, then as a second test user, and confirm neither can see or change the first user's rows. Then check your older tables: they keep the grants they had, so any with RLS off are still open (Advisors → Security Advisor lists them).
Or ask your AI tool to do it
Paste this into Lovable, Bolt, Cursor, Claude Code or whichever tool built your app. Review what it changes before you deploy.
My Supabase app fails with error 42501. Before changing anything, show me the exact error message and which table and role it names, and list that table's Row Level Security status, grants for anon, authenticated and service_role, and policies. If the message is "permission denied for table", write one migration that grants only the operations the app performs, only to the roles that need them (anon only for data meant for signed-out visitors, and then only select), enables row level security, and adds one policy per granted operation limited to the row's owner with (select auth.uid()) = user_id. If the message is "new row violates row-level security policy", fix the insert so user_id is the signed-in user (or default the column to auth.uid()) and make sure every update policy has a matching select policy. Never grant all privileges to anon, never disable RLS, never restore Supabase's old default privileges and never use the service_role key in browser code.
How this happens
Postgres returns 42501 (insufficient_privilege) both when a role lacks a privilege and when a row fails a Row Level Security policy. Until October 30, 2026, Supabase granted every new table in public to anon, authenticated and service_role automatically, so most apps only ever saw the RLS version. Supabase's change, announced in its changelog on April 28, 2026, default for new projects since May 30 and applied to all existing projects on October 30, removes those automatic grants. Postgres now rejects requests to a new table before RLS comes into play, until you grant access.
Check what your app exposes
The free check reads your live site the way an attacker would: it finds which Supabase project your app talks to and flags any secret key in your JavaScript. To test the tables themselves, add the database tests to the website security report.
Topic check: Supabase security check
Test your database, not just your code
The free check can only see your code. The website security report can add database tests: with test accounts you create, it checks whether a stranger or another signed-in user can read data they shouldn't. It also covers up to 30 pages and 40 JavaScript files, exposed files, headers and libraries, with the fix for each finding.
$19 once, including 20 runs over 30 days so you can fix things and check again.

Questions
The hint says GRANT SELECT ... TO anon. Should I run it?
Only if signed-out visitors should read that table. The hint names whichever role made the request. If your users are signed in, grant to authenticated and find out why the request had no session. If you do grant to anon, keep RLS on with a select policy that only shows public rows.
Is a grant to anon safe if RLS is on?
With RLS on, a role only sees the rows a policy allows, so anon with no policy sees nothing. The danger is a grant on a table with RLS off, or a policy of using (true) on data that isn't public.
Why did this only start now?
Supabase stopped granting new tables automatically on existing projects on October 30, 2026. Tables created before keep their old grants, so only tables added since then, often by an AI tool adding a feature, return this error.
Does the generator send my table names anywhere?
No. It runs in your browser and only builds text for you to copy. Nothing is sent to AppInspected or Supabase.
Can AppInspected check this?
The free check finds which Supabase project your app talks to and flags any secret key in your JavaScript. It can't see grants or policies. The website security report can add database tests that use your own test accounts to check whether a stranger or another user can read data they shouldn't.
Sources
- Supabase changelog: tables not exposed to the Data and GraphQL API automatically
- Supabase: Row Level Security
- Supabase GitHub discussion #45329
- PostgreSQL: error codes (42501 insufficient_privilege)