VibeCPR

← All fixes

Supabase · Breaking change

Fix Supabase "permission denied for table" (42501) on new tables after Oct 30, 2026

Updated (first published ) · Applies to: Supabase, Lovable, Bolt, v0, Cursor, Replit, Claude Code

TL;DR fix: Supabase no longer auto-grants new public tables to anon, authenticated and service_role. That is already the default for projects created since May 30, 2026, and it is enforced on existing projects starting Friday, October 30, 2026. It only affects new tables: tables that already exist keep their grants, but a table or view that a migration drops and recreates is new as far as Postgres is concerned. For each new table, put three things in the same migration: the minimum GRANTs each role needs, enable row level security, and policies that check (select auth.uid()). Do not "fix" it with grant all ... to anon.

Steps

  1. Confirm it is a missing grant, not an RLS policy. The API error has code 42501 and the message permission denied for table your_table, with a hint such as GRANT SELECT ON public.your_table TO anon. If the message instead says new row violates row-level security policy, the grant exists and a policy is blocking the row; that is a different fix.
  2. Check which roles have privileges on the table. In the SQL editor run: select grantee, privilege_type from information_schema.role_table_grants where table_name = 'your_table'; A new table with no rows for anon or authenticated is not reachable through supabase-js.
  3. Decide what each role really needs. Logged-out visitors (anon) usually need nothing, or SELECT only for genuinely public data. Signed-in users (authenticated) get only the operations your app performs. service_role is for server-side code. Never grant to anon just because the hint suggests it.
  4. Write grants, RLS and policies in one migration. Supabase's changelog says to treat the grant, enabling RLS, and the policies as a unit. Use the SQL below and keep it in a migration file so it is reviewable.
  5. Grant the sequence only if you use serial ids. Supabase also stops default privileges on new sequences. Tables with a serial or bigserial id need grant usage, select on the sequence for roles that insert; identity columns (the Supabase dashboard default) do not.
  6. Retest as a real user and run the Security Advisor. Log in through the app (the SQL editor bypasses grants and RLS), retry the action, then check the Data API exposure badge in Table Editor and the Security Advisor in the dashboard.

What changes, and when

From the official Supabase changelog:

“Once the change is rolled out to your project, new tables you create in public schema require an explicit opt-in (via a Postgres grant) before the Data API can see them. Existing tables are not affected in your project, they keep their current grants and stay reachable.”

DateWhat happens (per Supabase)
April 28, 2026Opt-in setting available at project creation
May 30, 2026New behavior becomes the default for new projects (gradual rollout)
October 23, 2026Final notice email to project owners and admins
October 30, 2026New behavior enforced on existing projects (affects new tables only)

It affects you if your app uses the Data API (supabase-js, any client library, or /rest/v1/ and /graphql/v1) and new tables get created in public without explicit grants. Supabase names AI coding tools directly: “Your AI coding tool, CLI script, or Management API call creates tables and expects them to be reachable over the Data API on creation.”

The error you’ll see

When a grant is missing, Supabase documents this PostgREST response:

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

Supabase’s troubleshooting guide notes 42501 errors are “often reported by clients as 401 or 403 errors.” In the app it usually shows up as an empty list, a failed save, or a toast saying “permission denied.” Postgres stops the request before Row Level Security runs, so rewriting your policies won’t help.

After Oct 30: how to tell if this is what broke your app

From Friday, October 30, 2026 the change is enforced on existing projects (projects created from May 30, 2026, or that opted in, already have it). It only affects tables created after the change.

Symptom: a feature built on a table created after the change fails with 42501 permission denied for table ... (often surfaced as 401/403), or the UI just shows an empty list because the frontend swallows the error. Check the /rest/v1/ response in the browser’s Network tab for the real code.

Check the grants on that table in the SQL editor (replace your_table):

-- No row for a role = that role has no grant = the Data API can't see the table as that role.
select grantee, string_agg(privilege_type, ', ' order by privilege_type) as privileges
from information_schema.role_table_grants
where table_schema = 'public' and table_name = 'your_table'
  and grantee in ('anon', 'authenticated', 'service_role')
group by grantee order by grantee;

-- Same check with has_table_privilege, for the two roles your frontend uses:
select r.role,
       has_table_privilege(r.role, 'public.your_table', 'select') as can_select,
       has_table_privilege(r.role, 'public.your_table', 'insert') as can_insert
from (values ('anon'), ('authenticated')) as r(role);
  • No rows / all false for the role your app uses: it’s this change. Apply the safe fix below, grants, RLS and policies in one migration.
  • Grants present but results are empty: not this change. RLS is on and no policy lets that role see the rows. Add a policy (and if inserts fail with “new row violates row-level security policy”, see that fix).
  • Old tables work, only new ones fail: expected. Existing tables keep their grants.
  • An “old” table or view suddenly fails: check whether a migration dropped and recreated it. See the next section.

We ran both queries on an embedded Postgres 18 with Supabase-style roles: a table created after the default grants were revoked returns no rows and false, and select as authenticated fails with permission denied for table (SQLSTATE 42501).

Diagnosis notebook: copy-paste, top to bottom

Added November 5, 2026. The checks from this page as one runnable sequence. Paste each block into the Supabase SQL editor in order (or save them as snippets). Set the table name once in block 1. Each block’s comment says what a “bad” result means.

Block 1: grants per role. No row for the role your app uses = missing grant = this 42501.

select grantee, string_agg(privilege_type, ', ' order by privilege_type) as privileges
from information_schema.role_table_grants
where table_schema = 'public' and table_name = 'your_table'
  and grantee in ('anon', 'authenticated', 'service_role')
group by grantee order by grantee;

Block 2: yes/no per operation. Any false for an operation your app performs fails with 42501.

select r.role,
       has_table_privilege(r.role, 'public.your_table', 'select') as can_select,
       has_table_privilege(r.role, 'public.your_table', 'insert') as can_insert,
       has_table_privilege(r.role, 'public.your_table', 'update') as can_update,
       has_table_privilege(r.role, 'public.your_table', 'delete') as can_delete
from (values ('anon'), ('authenticated')) as r(role);

Block 3: RLS and policies. Grants present but empty results or “new row violates row-level security policy” = a policy problem, not a grant problem.

select c.relrowsecurity as rls_on
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relname = 'your_table';

select policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public' and tablename = 'your_table';

Block 4: every public table with no grant for authenticated. Finds other new tables that will fail the same way.

select c.relname as table_name
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('r', 'v', 'p')
  and not has_table_privilege('authenticated', c.oid, 'select')
order by 1;

Block 5: serial sequences. Inserts on serial/bigserial tables also need sequence usage.

select s.relname as sequence,
       has_sequence_privilege('authenticated', s.oid, 'usage') as auth_usage
from pg_class s join pg_namespace n on n.oid = s.relnamespace
where n.nspname = 'public' and s.relkind = 'S';

Then apply the safe fix for the tables that need it, and retest from the app, since the SQL editor bypasses grants and RLS. If the query ran but .single() complains about 0 rows instead, that’s RLS hiding the row: see PGRST116 “JSON object requested, multiple (or no) rows returned”.

“Old” tables and views that break anyway

Supabase says existing tables keep their grants, and that’s true, but Postgres attaches grants to the table object, not its name. Anything that destroys and rebuilds the object gets a new one with no grants. We tested each case on embedded Postgres 18 with Supabase-style roles, after revoking the default grants the way the Oct 30 change does:

What your migration or AI tool doesGrants kept?Result as authenticated
alter table ... add columnYesWorks
alter table ... rename to ...YesWorks
drop table then create table (same name)No42501 permission denied for table
create view (new view, even on a granted table)No42501 permission denied for view
create or replace view on an existing viewYesWorks
drop view then create view (same name)No42501 permission denied for view

Watch out for ORM “reset” or “push” commands, AI agents that rewrite a schema file from scratch, and migrations that rebuild a view with drop view to change its columns. Put the grants (and enable row level security, plus with (security_invoker = true) for views) in the same migration that recreates the object.

To list every table and view in public that the authenticated role can’t read:

select c.relname as name,
       case c.relkind when 'v' then 'view' when 'm' then 'materialized view' else 'table' end as kind,
       has_table_privilege('authenticated', c.oid, 'select') as authenticated_select
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('r', 'p', 'v', 'm')
  and not has_table_privilege('authenticated', c.oid, 'select')
order by kind, name;

Not everything on that list should be readable: internal tables are often meant to stay private. Grant only the ones your frontend actually queries.

The unsafe “fix” AI tools reach for

Paste that error into an AI tool and the quickest way to make it go away is to open everything up:

-- DON'T: makes the error disappear by giving the public key every privilege
grant all on public.your_table to anon;
grant all on all tables in schema public to anon, authenticated;
alter table public.your_table disable row level security;

anon is the role behind your public (anon or publishable) key, which ships in your frontend. GRANT ALL also gives TRUNCATE, REFERENCES and TRIGGER, which the Data API never needs. If RLS is off or a policy says using (true), anyone can read or rewrite the table. Even the hint’s suggested GRANT SELECT ... TO anon is only right if logged-out visitors should actually read that table.

The safe fix: grants, RLS and policies in one migration

Supabase’s changelog says to “treat these three steps as a unit.” Here it is for a typical per-user table (rename notes and user_id):

-- 1. Least-privilege grants: only what the app actually does
--    (no anon grant: logged-out visitors can't touch this table)
grant select, insert, update, delete on public.notes to authenticated;
grant select, insert, update, delete on public.notes to service_role;

-- 2. Row Level Security on
alter table public.notes enable row level security;

-- 3. Policies that tie every row to the signed-in user
create policy "users read own notes"
  on public.notes for select to authenticated
  using ((select auth.uid()) = user_id);

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

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

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

-- Optional: fill user_id automatically
alter table public.notes alter column user_id set default auth.uid();

-- Only if the id is serial/bigserial (not an identity column):
-- grant usage, select on sequence public.notes_id_seq to authenticated;

For a genuinely public read-only table (say, a product catalog), grant select to anon and authenticated, enable RLS, and add a for select policy. Don’t grant insert, update or delete to anon.

Supabase’s docs say the same thing: “Bundle grants with your RLS setup in the same migration. The grant command controls role access. The enable row level security command and policies control row access.”

Prompt for Cursor, Lovable, Bolt or Claude Code

Supabase returns 42501 "permission denied for table <table>" for a new table.
Since Supabase's Data API grant change (enforced on existing projects Oct 30, 2026), new public tables have no default grants.
Fix it safely in ONE migration:
1. Grant only the privileges each role needs. No GRANT ALL. No grants to anon
   unless logged-out visitors must read this table, and then SELECT only.
2. alter table public.<table> enable row level security;
3. Add select/insert/update/delete policies for authenticated that check
   (select auth.uid()) = user_id (USING and WITH CHECK as appropriate).
Do NOT disable RLS, do NOT use USING (true) / WITH CHECK (true).
From now on, every new table you create must include its grants, RLS and
policies in the same migration. Show me the SQL before running it.

Want the new behavior early (or on staging)?

If enforcement hasn’t reached a project yet, Supabase’s changelog gives the statements to opt it in (run in the SQL editor). Existing objects keep their grants:

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

alter default privileges for role postgres in schema public
  revoke usage, select on sequences from anon, authenticated, service_role;

Reproduce the error in two minutes (and see the fix work)

Run this in a test project or any local Postgres. It simulates what a project looks like after the change: no default grants, so a new table is invisible to the Data API roles. (We ran these statements on an embedded Postgres 18 to confirm the messages.)

-- Simulate the new default: no automatic grants on new public tables
alter default privileges for role postgres in schema public
  revoke select, insert, update, delete on tables from anon, authenticated, service_role;

create table public.notes (
  id bigint generated always as identity primary key,
  user_id uuid not null default auth.uid(),
  body text
);

-- Act as a signed-in user, the way supabase-js does:
set role authenticated;
select * from public.notes;
-- ERROR: permission denied for table notes     <- the 42501 your app sees as an empty list or failed save
insert into public.notes (body) values ('hi');
-- ERROR: permission denied for table notes
reset role;

Now the copy-paste fix: least-privilege grants, RLS on, policies scoped to auth.uid(). Keep it all in one migration.

grant select, insert, update, delete on public.notes to authenticated;
grant select, insert, update, delete on public.notes to service_role;  -- server-side only
-- no grant to anon: logged-out visitors can't touch this table

alter table public.notes enable row level security;

create policy "own read"   on public.notes for select to authenticated using ((select auth.uid()) = user_id);
create policy "own insert" on public.notes for insert to authenticated with check ((select auth.uid()) = user_id);
create policy "own update" on public.notes for update to authenticated
  using ((select auth.uid()) = user_id) with check ((select auth.uid()) = user_id);
create policy "own delete" on public.notes for delete to authenticated using ((select auth.uid()) = user_id);

Re-test: as authenticated the insert and select now succeed and return only your own rows, and as anon the same select still returns permission denied, which is what you want for a private table.

A 10-minute checklist (before or after Oct 30)

The change only touches new tables, so nothing you already shipped breaks on October 30. What breaks is the next table your AI tool creates. Do this once:

  1. Add the grant step to your AI tool’s instructions. Put this line in your Cursor rules, Lovable knowledge or CLAUDE.md: “Every new table in public needs explicit GRANTs, enable RLS and auth.uid() policies in the same migration. Never GRANT ALL to anon. Never disable RLS.”
  2. Audit what you already have. In Security Advisor, clear the RLS-disabled and permissive-policy findings. Our USING (true) guide covers the always-true policies.
  3. Audit your views. Existing tables keep their grants on Oct 30, and so do existing views. Postgres views run as their owner and skip RLS, and a view with default anon write grants lets your public key delete or edit rows. Use the views audit and fix.
  4. Not enforced on your project yet? Use the opt-in statements above on staging first, so you find any breakage on your terms.
  5. Provisioning flows: if you create Supabase tables for your own customers, bundle the GRANTs into the provisioning migration.

The case for acting now: a view, a default grant and 35,000 profiles

On October 23, 2026 the builder Max Hirsch posted that his app was hacked overnight and 35,000 profiles were wiped. By his own account he had “bypassed RLS with a view so users could see each other’s profiles, and didn’t revoke Supabase’s default anon permissions, so the public key could delete everyone through it.” It’s a good example of how grants and RLS are separate layers: RLS was on, and it didn’t matter, because the view ran as its owner and anon still held the default write grants.

The Oct 30 change makes this class of mistake harder for new tables, but it does nothing for objects that already exist. If you have a view, check it:

-- Which views can the public key read or write?
select c.relname as view_name,
       coalesce('security_invoker=true' = any(c.reloptions), false) as security_invoker,
       has_table_privilege('anon', c.oid, 'select') as anon_can_select,
       has_table_privilege('anon', c.oid, 'insert,update,delete') as anon_has_write_grant
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('v','m') order by 1;

-- Fix, per view:
revoke insert, update, delete, truncate on public.your_view from anon, authenticated;
alter view public.your_view set (security_invoker = true);  -- Postgres 15+

Full walkthrough, including a reproduction and what to do if users need to see each other’s public fields: Fix a Supabase view that bypasses RLS.

More background: Supabase’s October 30, 2026 change explained, check your Supabase RLS in two minutes, fix USING (true) publicly readable policies, and, if a Realtime subscription on a new table receives nothing, fix Supabase Realtime not receiving changes.

When to get help

Get help if a lot of tables or migrations were created by an AI tool and you're not sure which ones should be public, if your agent keeps adding GRANT ALL or disabling RLS to make the error go away, or if your platform provisions Supabase projects for customers and the provisioning flow doesn't add grants yet.

FAQ

Does the October 30, 2026 change fix or cause the "view bypasses RLS" problem?

Neither. Oct 30 only changes default grants for new tables in the public schema on existing projects (projects created from May 30, 2026 already had it). Views you already created, and tables that already exist, keep their current grants. If a view still has anon write grants, it stays dangerous after Oct 30. On October 23, 2026 a builder reported losing 35,000 profiles through exactly that setup, a view that skipped RLS plus default anon permissions. See the fix: https://vibecpr.com/fix/supabase-view-bypasses-rls-security-invoker

What exactly changes in Supabase on October 30, 2026?

Supabase's changelog says the setting is enforced on existing projects on October 30, 2026: new tables created in the public schema require an explicit GRANT before the Data API (REST, GraphQL, supabase-js) can see them. Projects created since May 30, 2026 already behave this way by default. Existing tables are not affected and keep their current grants.

Will my existing tables break on October 30?

No, according to Supabase: "Existing tables are not affected in your project, they keep their current grants and stay reachable." The break happens the first time you or an AI tool creates a new table in public without an explicit GRANT.

Why not just run GRANT ALL ON the table TO anon?

GRANT ALL hands anon (anyone holding your public key) every table privilege, including TRUNCATE, REFERENCES and TRIGGER, which the Data API never needs. If RLS is off or a policy is too loose, anyone can read or rewrite the table. Grant only the operations each role uses, and keep RLS on with policies.

Is this the same as "new row violates row-level security policy"?

No. Both are 42501, but "permission denied for table" means the role has no GRANT on the table, so Postgres rejects the query before RLS is checked. "new row violates row-level security policy" means the grant exists and an RLS policy blocked the write.

Does this affect direct Postgres connections or other schemas?

Supabase says you are unaffected if you only use a direct Postgres connection (psql, an ORM, or a server with a connection string). Tables in storage, auth, realtime and custom schemas keep their current grants and defaults.

How do I tell if the Oct 30 change is what broke my app?

Check whether the failing table was created after the change and whether the Data API roles have grants on it. In the SQL editor run: select grantee, string_agg(privilege_type, ', ') from information_schema.role_table_grants where table_schema = 'public' and table_name = 'your_table' and grantee in ('anon', 'authenticated') group by grantee; No rows means no grant, so this change is the cause. If the grants are there and you get empty results, Row Level Security is filtering the rows (usually a missing policy), which is a different fix.

My table existed before Oct 30, so why does it return 42501 now?

Probably because something dropped and recreated it. Grants belong to the table object, not its name, so a migration, ORM reset or AI tool that runs drop table then create table produces a brand-new table with no grants. The same goes for views: create view (or drop view then create view) makes a new object with no grants, while create or replace view on an existing view keeps them. alter table add column and rename keep grants. We verified each case on Postgres 18 with Supabase-style roles. Re-add the grants in the same migration that recreates the object.

Can I switch to the new behavior early?

If enforcement hasn't reached your project yet, yes. Supabase's changelog gives alter default privileges ... revoke statements for the postgres role in the public schema. Existing objects keep their grants, so your running app stays reachable; only future tables need explicit grants.

Sources

Related fixes