Guide Supabase

Supabase error 42501 "permission denied for table": what it means and the safe fix

Short answer

Error 42501 means your database blocked the request. Either your access rules don't allow it (Row Level Security, or RLS), or the table isn't open to the role your app uses (a missing grant). If the message says "new row violates row-level security policy", it's the rules. If it says "permission denied for table", it's the grant.

The safe fix: make sure the person is signed in, keep RLS on, add a rule that lets each signed-in user reach their own rows, and grant the table to signed-in users (the authenticated role). Don't turn RLS off, and don't put your secret key in the app to make the error go away.

RLS means Row Level Security. Grants decide whether a role can reach a table at all; RLS decides which rows it can see (Supabase: Securing your API).

This change has not happened yet. Supabase plans to apply it to existing projects on October 30, 2026. As of it has not reached existing projects. We'll check this page again after that date.

Don't make the error go away like this

Each of these can make the error go away, and each one can open your data to strangers:

  • Turning RLS off. Supabase: "A table in an exposed schema without RLS is readable and writable by any role with a grant on it."
  • A rule that lets everyone in, on private data (using (true)). Supabase: it "grants every unauthenticated visitor read access to every row the role can already reach through grants. Use it only for data that is meant to be public."
  • Putting your all-access key in the app (the service_role key or a secret key, sb_secret_). Supabase: "A secret key bypasses every Row Level Security policy you have. Never put one in a browser, a shipped application, or source control."
  • Pasting GRANT ALL ... TO anon because a hint or an AI tool suggested it. Why that's risky.

Fix it in 5 steps

Work through these in order and stop at the step that finds the cause.

Step 1: Check that you're signed in

Your database treats a signed-out visitor and a signed-in user as two different people (the anon and authenticated roles). A rule like "each user sees their own rows" can't match someone who isn't signed in, because the database doesn't know who they are (auth.uid() returns null). Supabase says the same happens when "no access token is provided or the session has expired."

What to do: sign in to your app and try the same action again.

  • Works when signed in, fails when signed out: your rules are doing their job. Ask people to sign in before that page or button.
  • Fails when signed in too: go to step 2.

Step 2: Check whether RLS is on

RLS is the set of access rules on each table. You want two things: RLS turned on, and at least one rule (a policy) for each thing your app does.

On your own Supabase project: open the SQL editor and run this. It only reads settings and changes nothing:

select c.relname as table_name,
       c.relrowsecurity as rls_on,
       has_table_privilege('anon', c.oid, 'select') as anon_select,
       has_table_privilege('authenticated', c.oid, 'select') as auth_select,
       (select count(*) from pg_policies p
         where p.schemaname = n.nspname and p.tablename = c.relname) as policies
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('r', 'p')
order by rls_on, table_name;

On Lovable Cloud: go to More, then Database, then Manage, then Policies. That view is read-only. To change a rule, ask Lovable in the project chat (step 3 has a prompt).

On Bolt's built-in database: open the Security tab. Bolt says it "uses the same database checks as the Security Advisor in Supabase."

How to read it:

  • RLS on, 0 policies: the rules block everything. If the role has a grant, reads come back as an empty list (no error), changes match no rows, and saving a row fails with "new row violates row-level security policy". If the role has no grant (anon_select or auth_select is false), you get "permission denied for table" instead (step 4). Add rules in step 3.
  • RLS off: anyone with a grant can read and change the table. Turn RLS on in the same change as the rules in step 3, so your app doesn't go blank in between.
  • RLS on, with policies: check what the rules allow (step 3), then the grants (step 4).

Step 3: Add a rule so each user reaches their own rows

This is Supabase's recommended fix: the grant, turning on RLS and the rules you need, shipped together as one change. Here's an example for an orders table where each row belongs to one signed-in user through a user_id column. Change the names to match your table.

begin;
alter table public.orders enable row level security;
revoke all on table public.orders from anon, authenticated;
grant select, insert, update, delete on table public.orders to authenticated;

create policy "orders_select_own" on public.orders
  for select to authenticated
  using ((select auth.uid()) = user_id);

create policy "orders_insert_own" on public.orders
  for insert to authenticated
  with check ((select auth.uid()) = user_id);

create policy "orders_update_own" on public.orders
  for update to authenticated
  using ((select auth.uid()) = user_id)
  with check ((select auth.uid()) = user_id);

create policy "orders_delete_own" on public.orders
  for delete to authenticated
  using ((select auth.uid()) = user_id);
commit;

Turn RLS on first and run it in one transaction, so there's no moment where the new grant works without the row rules.

If saving a row still fails with "new row violates row-level security policy": your app has to put the signed-in user's id in user_id when it saves the row. If that column is empty or holds someone else's id, the insert rule rejects it, and that's the rule working. (If your app saves and reads back in one call, like .insert().select(), the read rule has to allow the new row too.)

Signed-out visitors need to see this table? (A public product list, say.) Grant anon select on that table and add a read rule for anon. Use using (true) only for data that is meant to be public.

Your own server code reads or writes this table? Supabase's changelog example also grants service_role:

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

Server code that uses a secret key runs as service_role. It skips RLS, but it still needs the grant: Supabase says a missing grant returns a permission error, including for service_role. Keep that key server-side.

If orders.id is a serial or bigserial column and the table was created without the old default grants (a new project, or after the change reaches your project), saving rows also needs grant usage on sequence public.orders_id_seq to authenticated;.

On Lovable Cloud, ask Lovable in the project chat, for example: "Turn on Row Level Security for the orders table and add one policy per action (select, insert, update, delete) so each signed-in user can only reach rows where user_id is their own id. Grant the table to authenticated users only. Don't turn Row Level Security off and don't use using (true)." Then check the new rules under More, then Database, then Manage, then Policies.

Then test it: sign out and try to read the table with only the public key. You should get an error or an empty list. Then sign in as two test users and check that user B can't see user A's rows. Only test apps you own or are authorized to test.

Step 4: Check the grants for signed-out and signed-in users

Before any rule runs, the database checks whether the role may touch the table at all (a grant). Supabase: "A missing grant raises a 42501 error before any policy runs. When a request fails that your policy should allow, check the grants before you change the policy."

Run this in the SQL editor (change orders to your table name):

select grantee, privilege_type
from information_schema.role_table_grants
where table_name = 'orders';

How to read it:

  • authenticated should have each action your app does for signed-in users (SELECT, INSERT, UPDATE, DELETE). A missing one gives "permission denied for table". Add it with the grant ... to authenticated line from step 3.
  • anon should have SELECT for data signed-out visitors need to see, and nothing else.

The error comes with a hint that suggests a GRANT ... TO anon line. Read it before you copy it: the hint names the role that made the request, which is anon whenever the user isn't signed in. If RLS is off on that table, running the suggested grant lets anyone with your public key read it.

Why this will matter more after October 30, 2026: Supabase plans to stop exposing new tables in the public schema of existing projects to the Data API until you grant access. A table you add after the change reaches your project will give "permission denied for table" until you grant it. Existing tables keep their current grants. New projects have worked this way since the May 30, 2026 rollout. Details below.

Step 5: Why the SQL editor works but your app doesn't

Supabase's SQL editor doesn't run your query as one of your app's users. Supabase's docs say "Queries you run in the Dashboard execute as postgres," the default role that "has admin privileges," and that on Supabase postgres "has bypassrls," the Postgres setting that lets a role skip Row Level Security. Your app runs as a signed-out visitor (anon) or a signed-in user (authenticated), so it meets every rule and grant.

So a query that works in the SQL editor doesn't prove your app can run it, or that your rules protect anything. Test from the app, signed out and signed in as two test users. Supabase Studio also has a role selector that can run a query as anon or as a signed-in test user, to try your rules.

On Lovable Cloud, Lovable's docs don't say which role its SQL editor uses, so test from the app itself.

What will Supabase change on October 30, 2026?

Supabase's changelog says that once the change reaches a project, “new tables you create in public schema require an explicit opt-in (via a Postgres grant) before the Data API can see them.” The Data API is Supabase's auto-generated REST and GraphQL layer (Supabase changelog).

Supabase's planned timeline:

  • From April 28, 2026: new projects could opt in when they were created.
  • From May 30, 2026: the new behavior became the default for all new projects, rolled out gradually over a few weeks.
  • On October 30, 2026: Supabase plans to apply it to all existing projects.

What stays the same, according to Supabase:

  • Existing tables keep their current grants and stay reachable.
  • RLS behavior is unchanged.
  • Apps that only use a direct Postgres connection are not affected.
  • Only the public schema is affected. Tables in storage, auth, realtime and custom schemas are unaffected.

What does error 42501 look like?

When a grant is missing, the Data API returns error 42501 with a message like this (Supabase changelog):

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

The hint names the role that made the request, which is anon whenever the user isn’t signed in. If RLS is off on that table, running the suggested grant lets anyone with your public key read it.

Same code, different cause: if the message says "new row violates row-level security policy", your grant is fine. An RLS rule's with check rejected the row. Fix the rule (step 3), leave the grants alone, and don't turn RLS off.

Which of my tables are exposed right now?

Run in the SQL editor (it only reads the catalog):

select c.relname as table_name,
       c.relrowsecurity as rls_on,
       has_table_privilege('anon', c.oid, 'select') as anon_select,
       has_table_privilege('authenticated', c.oid, 'select') as auth_select,
       (select count(*) from pg_policies p
         where p.schemaname = n.nspname and p.tablename = c.relname) as policies
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('r', 'p')
order by rls_on, table_name;

How to read it:

  • rls_on false and anon_select true: anyone with your public key can read the table through the API. Fix these first.
  • rls_on true and policies 0: the API returns an empty list, not an error. Nothing leaks, but your app sees no rows until you add policies.
  • rls_on true with policies: check what those policies allow (see the FAQ on using (true)).
  • anon_select and auth_select both false: the API can’t reach the table, and a request gets 42501 “permission denied for table”. That’s how a new table will look on existing projects after October 30, 2026 until you grant access.

This query checks table-level grants only. A column-level grant shows as false.

Why is GRANT ALL to anon the wrong fix?

An AI tool may suggest a quick fix: grant all on the table to anon, the role behind your app's public key. The error goes away. Here's why that's risky.

Supabase explains the order of checks: If the grant is missing, Postgres rejects the query before RLS comes into play. (Supabase changelog) Grants decide whether a role can reach a table. RLS decides which rows it can see. So once the grant exists, Row Level Security is the only thing left between a visitor and your data.

If RLS is off on that table, Supabase's own Security Advisor puts it plainly: Anyone with your project URL can read, edit, and delete all data in this table because Row-Level Security is not enabled. (Supabase: Database Advisors, lint 0013)

Supabase's advice is to Use both controls for every exposed object. (Supabase: Securing your API)

Two places the Oct 30 fix can quietly be undone

1. A default grant to anon

alter default privileges decides what every future table gets. One ... grant select on tables to anon puts the old behavior back: each new table is readable at creation. Check:

select pg_get_userbyid(d.defaclrole) as for_role,
       coalesce(n.nspname, '(all schemas)') as in_schema,
       case d.defaclobjtype when 'r' then 'tables' when 'S' then 'sequences'
            when 'f' then 'functions' when 'T' then 'types' when 'n' then 'schemas' end as object_type,
       a.grantee::regrole as grantee,
       string_agg(a.privilege_type, ', ' order by a.privilege_type) as privileges
from pg_default_acl d
left join pg_namespace n on n.oid = d.defaclnamespace
cross join lateral aclexplode(d.defaclacl) a
where a.grantee in (select oid from pg_roles where rolname in ('anon', 'authenticated'))
group by 1, 2, 3, 4
order by 1, 2, 3, 4;

Reading it: until Supabase’s change reaches your existing project, rows for postgres / public / tables are expected, because that is the old default. After the change (or after you opt in early), a tables row for anon or authenticated in public means new tables are exposed again. Remove it with Supabase’s own opt-in statement (Supabase changelog):

alter default privileges for role postgres in schema public revoke select, insert, update, delete on tables from anon, authenticated, service_role;

2. Views

“Views bypass RLS by default because they are usually created with the postgres user.” (Supabase Docs: Row Level Security) List views and whether they run as the caller:

select c.relname as view_name,
       coalesce((select lower(o.option_value) in ('true', 'on', '1', 'yes')
                 from pg_options_to_table(c.reloptions) o
                 where o.option_name = 'security_invoker'), false) as security_invoker,
       has_table_privilege('anon', c.oid, 'select') as anon_select
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind = 'v'
order by 1;

Fix a view with security_invoker false:

alter view public.your_view set (security_invoker = true);

Afterward the caller needs its own grant on the underlying table.

Can new Supabase projects show the same error?

Yes. New projects have had this behavior by default since the May 30, 2026 rollout, so a brand new Supabase project may need the same grants today (Supabase changelog).

What should I tell Lovable or Bolt?

If you build with Lovable, Bolt or another AI tool, give it the rule before it writes the migration. You can paste this:

When you add a new table to Supabase, write one migration that does three things together: grant only the access each role needs (no GRANT ALL to anon), enable Row Level Security on the table, and add one policy per operation that limits each signed-in user to their own rows. Do not turn Row Level Security off to make an error go away.

Then check the migration it writes against the example above before you run it.

On Lovable Cloud you can see every rule Lovable wrote under More, then Database, then Manage, then Policies.

What else do people ask about error 42501?

Do my existing tables break?

No. Supabase says existing tables keep their current grants and stay reachable through the Data API, and RLS behavior is unchanged. The change is about new tables you create in the public schema.

Does this affect storage or auth tables?

No. The change affects default privileges in the public schema only. Tables in storage, auth, realtime and custom schemas are unaffected, and apps that only use a direct Postgres connection are not affected.

Where do I see affected tables?

In the Supabase Security Advisor. Supabase says: "From today through October 30, the Security Advisor flags affected tables per project and shows the remediation SQL." Supabase also planned email notices to owners and admins of active projects on September 23 and October 23, 2026.

Source for all three answers: Supabase changelog, “Breaking Change: Tables not exposed to Data and GraphQL API automatically”.

How do I find policies that let anyone read a table even with RLS on?

Run:

select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
  and roles && array['anon', 'authenticated', 'public']::name[]
  and (qual = 'true' or with_check = 'true')
order by tablename, policyname;

A SELECT row with qual true for {anon} or {public} ({public} means the policy has no TO clause) lets anyone with your public key read every row. An INSERT row with with_check true for anon lets anyone add rows. {authenticated} means every signed-in user. That’s fine only for data meant to be public. The query matches only a literal true, so also read any policy you didn’t write. Supabase’s Security Advisor doesn’t flag always-true read policies; its check skips them by design.

Sources for the last answer: Supabase Docs: Row Level Security; Supabase Docs: Database Advisors.

Why does my query work in the Supabase SQL editor but not in my app?

The SQL editor runs as the postgres role, which bypasses Row Level Security. Your app runs as a signed-out visitor (anon) or a signed-in user (authenticated), so it has to pass your grants and RLS rules. Test from the app, signed out and signed in.

What does "new row violates row-level security policy" mean?

RLS is on and no rule allows the row you're saving. Add an insert rule like with check ((select auth.uid()) = user_id) and make sure your app puts the signed-in user's id in user_id. If your app reads the row back after saving, it needs a read rule too. Don't turn RLS off.

Why does my app show no data but no error?

If RLS is on, that's what it looks like when no read rule matches. Supabase: "Once RLS is enabled, no data is accessible through the API when using a publishable key, until you create policies." Check that the person is signed in, then add a read rule.

Can I fix error 42501 by turning off RLS?

No. The error goes away, but a table without RLS "is readable and writable by any role with a grant on it," per Supabase. Keep RLS on and add the rules your app needs.

Where do I see my access rules in Lovable Cloud?

Go to More, then Database, then Manage, then Policies. The view is read-only. To change a rule, ask Lovable in the project chat.

Want a second pair of eyes?

Not sure your rules are right? Start with the free instant check: an automated scan of your homepage and its scripts, with results on screen in seconds. It doesn't store your results. It can't see inside your database, so it won't find a missing rule or grant. For app owners or people they authorize.

To have your database looked at, the $49 Database Check: a person checks who can see or change your app's data, table by table, and tells you what to fix first. We change nothing. Your report within 24 hours of working access, or a full refund if you ask within 14 days of purchase.

To have it fixed, the Security Fix ($149) covers RLS fixes, storage policies, a check of the code your app sends to browsers for secret keys (bundle key scan), key rotation guidance and a short report. Every critical issue on our checklist fixed within 48 hours of working access. Otherwise, a full refund if you ask within 14 days of purchase. AI agents run the checks and a human engineer approves every change. It's not a penetration test, a security guarantee or a compliance certification.

Prefer to do it yourself? Use the free Supabase RLS checklist.

Where do these facts come from?

  1. Supabase changelog: Breaking Change: Tables not exposed to Data and GraphQL API automatically. Published 28 Apr 2026. Timeline, scope, error 42501, the recommended fix and the Security Advisor.
  2. Supabase Docs: Securing your API. Grants and RLS.
  3. Supabase Docs: Row Level Security. Grants vs RLS, views and security_invoker, and postgres has bypassrls.
  4. PostgreSQL Docs: ALTER DEFAULT PRIVILEGES. Default grants for future tables.
  5. Supabase Docs: Database Advisors. Lint 0013, RLS disabled on a public table.
  6. Supabase Docs: Database API 42501 errors. The grant check query, and inserts or updates without RLS permission return 42501.
  7. Supabase Docs: Postgres Roles. Dashboard queries run as postgres, which has admin privileges.
  8. Supabase Blog: Supabase Studio: AI Assistant and User Impersonation. Switching roles in Studio.
  9. Supabase Docs: API keys. Secret keys bypass RLS.
  10. Lovable Docs: Database. Where to see RLS policies in Lovable Cloud.
  11. Bolt Support: Database security.
  12. PostgreSQL Docs: CREATE POLICY. Insert rule violations; RETURNING needs the read rule.
  13. PostgreSQL Docs: Row Security Policies. Roles with BYPASSRLS skip row security.

All sources checked on . Our own guidance is labeled as ours.