MondayMedic

Guide

Supabase permission denied for table

MondayMedic checks for common public mistakes. It is not a full security audit, and a good score does not mean your app is safe.

Check your live app first. Paste your app's public link into the free MondayMedic check. It reads only public pages and scripts, takes about a minute and needs no account. It flags Supabase tables the public key can read and secret keys in the browser. It does not change data, and it is not a full security audit.

Check my app free

The short answer

Your RLS is probably fine. The new table is missing a grant. Supabase is changing a default: on 30 October 2026 it starts applying to existing projects, so new tables in the public schema are no longer reachable through the Data API until you grant access. Without a grant, supabase-js gets this back:

{
  "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 fix is to grant each role only what it needs on that table, keep RLS on, and do both in the same migration. Existing tables aren't affected.

What exactly changed in Supabase?

Until now, every table you created in public was automatically granted select, insert, update and delete for the anon, authenticated and service_role roles, so it was reachable through the Data API the moment it existed. Supabase's changelog sets out the rollout: an opt-in setting from 28 April 2026, the new default for new projects from 30 May 2026, and all existing projects from 30 October 2026.

After the change reaches your project, a new table exists but the API can't see it until you run a grant. This only affects apps that use the Data API, which is what supabase-js and apps built with Lovable or Bolt normally use. If your app only talks to Postgres over a direct connection string, nothing changes.

Is this an RLS problem?

No. Grants and Row Level Security are two separate locks:

If the grant is missing, Postgres refuses the query before RLS runs. So rewriting your policies, or asking your AI builder to "fix RLS", won't help, and turning RLS off to make the error go away would be a real mistake.

How do I check which grants a table has?

In the Supabase dashboard, open the SQL Editor and run this with your table's name:

select grantee, privilege_type
from information_schema.role_table_grants
where table_schema = 'public' and table_name = 'your_table'
order by grantee, privilege_type;

If anon or authenticated is missing from the list, that's your 42501.

What is the safe fix?

Grant only what each role needs, then make sure RLS is on with policies that match. Supabase's own pattern treats these three steps as one unit:

-- 1. Grant what each role needs (least privilege)
grant select on public.your_table to anon;                                  -- only if logged-out visitors should read it
grant select, insert, update, delete on public.your_table to authenticated; -- signed-in users; RLS still applies
grant select, insert, update, delete on public.your_table to service_role;  -- server-side code

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

-- 3. Add policies, for example: users only see their own rows
create policy "own rows" on public.your_table
  for select to authenticated
  using (auth.uid() = user_id);

Leave out the anon line for anything private, like profiles, orders or messages. If the table uses a sequence or a function the app calls, those may need grants too; the error hint names exactly what is missing.

How do I fix it in Lovable or Bolt?

Paste the error and a request like this into the chat:

New Supabase tables no longer get Data API access by default, and the
"your_table" table returns 42501 permission denied. In a new migration,
add explicit GRANTs: select/insert/update/delete to authenticated and
service_role, and select to anon only if logged-out users must read it.
Keep RLS enabled and keep the existing policies. Do not disable RLS.
From now on, include these grants in every migration that creates a table.

Then check the result with the SQL above, and test the page once logged out and once as a second user to make sure nobody sees rows that aren't theirs.

Should I turn automatic exposure back on?

Supabase's docs describe a setting in the Data API section of the dashboard for automatically exposing new tables, and say grants for new tables can be managed there or in SQL. Switching it back on makes the error disappear, but it also means every future table is reachable with your public key the moment it's created. For a vibe-coded app, where tables get created by an AI without you looking, explicit grants per table are the safer habit.

Add MondayMedic as a preferred source on Google

Related guides

Want a weekly look from the outside? Run the free check on your live app.

FAQ

Why does my new Supabase table return permission denied for table?

Since Supabase's change rolls out to existing projects on 30 October 2026, new tables in the public schema no longer get automatic grants for the anon, authenticated and service_role roles. Without a GRANT, the Data API (what supabase-js uses) returns error 42501 before RLS is even checked.

Is my RLS policy wrong if I get error 42501?

Usually not. Grants and RLS are separate layers. The grant decides whether a role can touch the table at all; RLS decides which rows it sees. A 42501 'permission denied for table' error on a new table normally means the grant is missing, not the policy.

Are my existing Supabase tables affected?

No. Supabase says existing tables keep their current grants and stay reachable. Only tables created after the change reaches your project need an explicit grant.

Should I just turn automatic exposure back on?

It's safer not to. Granting only what each role needs, table by table, means a table you never meant to expose can't be read through your public key. If you do switch it back on, make sure every table has RLS enabled.

Will MondayMedic catch this?

The free check reads your live app from the outside and flags Supabase tables the public key can read and secret keys in the browser. It can't see your grants or tell you why a table is refusing requests, so use the SQL in this guide for that.

Sources