App Finishers

Fix guide · updated 2026-11-08

Supabase "permission denied for table" (42501) since October 30: the safe fix

permission denied for table profiles · code 42501 · permission denied for sequence

Your app worked, then you added a table, and now Supabase answers 401 or 403 with permission denied for table profiles (code 42501). Nothing is wrong with your RLS. Since October 30, 2026, Supabase no longer opens new tables to your app automatically: each one needs an explicit GRANT first. Here's the safe fix, the error that often comes next, and the quick fix that reopens your data to anyone.

What changed on October 30

Until this change, every table you created in the public schema was reachable through Supabase's Data API right away: anon, authenticated and service_role got select, insert, update and delete on it by default. Supabase announced the switch on April 28, 2026, made it the default for new projects from May 30, and applied it to all existing projects on October 30.

Is it this error, or an RLS error?

Two different problems share the code 42501, and the API answers both with 401 when the user is signed out and 403 when signed in. Read the message:

The API's answer also carries a hint naming the missing privilege, for example GRANT SELECT ON public.your_table TO anon;. It tells you what's missing. It doesn't tell you whether that role should have it.

The fix: grant each role what it needs, together with RLS

Supabase calls these three steps a unit: the grant, RLS, and the policies. Run them in the SQL Editor or put them in the migration that creates the table. Example for a profiles table:

-- 1. Grants: only the roles and actions your app uses
grant select, insert, update, delete on public.profiles to authenticated;
grant select, insert, update, delete on public.profiles to service_role;
-- grant select on public.profiles to anon;  -- only if signed-out visitors must read it

-- 2. RLS on
alter table public.profiles enable row level security;

-- 3. Policies: which rows each user may touch
create policy "own profile" on public.profiles
  for all to authenticated
  using (auth.uid() = id) with check (auth.uid() = id);

Which role is which:

We rebuilt Supabase's three roles on a test PostgreSQL 16 database and ran each step. With RLS and a correct policy but no grant, the insert failed with permission denied for table. After the grant, it went through.

Next error: "permission denied for sequence"

Once the table grant is in, inserts can fail again with permission denied for sequence todos_id_seq. The table's id is a serial column, which draws numbers from a separate sequence, and the new default doesn't grant that either. Grant it to the roles that insert:

grant usage on sequence public.todos_id_seq to authenticated;

Ids made with generated ... as identity or a uuid default don't need this. In our test, the identity-column table took inserts with the table grant alone.

Don't fix it with GRANT ALL

Two quick fixes make the error disappear, and an AI assistant may offer either one:

A grant only decides who may touch a table. RLS decides which rows. If any table lacks RLS, the grant opens all of it to anyone with your public key. We tested the rollback: we restored the defaults, then created a table without RLS. A signed-out user (anon) read its private row and wrote a new one. Grant table by table instead, and only to the roles that need it.

Find every table that needs a grant

Paste this in the SQL Editor. It lists each table in public, whether RLS is on, and what each role can do:

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,
       has_table_privilege('authenticated', c.oid, 'insert') as auth_insert
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 1;

A table your app uses with false in the role's column needs a grant. A table with rls_on = false and true under anon_select is readable by anyone: turn RLS on before anything else. Supabase also flags tables in the Security Advisor, and shows a Data API exposure badge in the Table Editor.

If an AI tool builds your database

Lovable, Bolt, Cursor and Claude Code create tables through migrations. If a migration has no GRANT, the new table stays closed. Tell the AI once, in its project instructions or in your next prompt:

For every new table in the public schema, add explicit GRANT statements in the same migration as ENABLE ROW LEVEL SECURITY and the policies. Grant only the roles that need access: authenticated for signed-in features, service_role for server code, anon only for data signed-out visitors must read. Never grant to anon by default, and never use GRANT ALL.

Then check its migration for those three parts before you accept it. If you use Supabase's own agent skill, Supabase says it already includes the grants step.

Functions work differently

Your database functions (the ones you call with rpc()) don't follow the table rule: in Postgres, every new function can be executed by PUBLIC, meaning every role. That's also why revoke execute on function ... from anon alone doesn't lock a function. In our test, anon still ran it through PUBLIC. To really lock one, revoke from both, then grant back the roles that need it:

revoke execute on function public.my_function from public, anon;
grant execute on function public.my_function to authenticated;

If several functions share that name, add the argument types, for example public.my_function(uuid).

Still stuck?

Check that you're editing the right project: the Supabase URL in your app's settings should match the project open in the dashboard. Then run the audit query again after each grant. Supabase has a support form for this change, linked at the end of their changelog post, with its full timeline and SQL.

Other Supabase problems? See Supabase fixes.