Supabase "permission denied for table" (42501) after October 30: what changed and how to fix it
You add a new feature, your AI tool creates a new table, and the app stops working the moment it touches it. The page stays empty, a save button does nothing, and the browser console or network tab shows this from Supabase:
{
"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;"
}
Nothing is wrong with your login or your policies. Supabase changed a default. Starting October 30, 2026, new tables in the public schema of existing projects are no longer exposed to the Data API automatically (Supabase changelog). New projects have worked this way since a gradual rollout that began on May 30, 2026. Supabase is sending a final notice email to project owners on October 23.
This hits apps built with Lovable, Bolt, Cursor, v0 and Replit hard, because those tools create tables for you and the app talks to them through supabase-js. This guide explains what the change does, how to tell it apart from an RLS problem, and the safe fix.
What changed, in one table
| Step | Before the change | After the change |
|---|---|---|
Create a table in public | Reachable through the Data API right away | Exists, but the Data API can't see it |
Grants to anon, authenticated, service_role | Added for you by default privileges | You add them with explicit grant statements |
| Row Level Security and policies | Unchanged | Unchanged |
Two details matter. First, existing tables are not affected: they keep their current grants and stay reachable. Only tables created after the change reaches your project need the extra step. Second, the change only touches the Data API, the REST and GraphQL layer that supabase-js and the other client libraries call. If your server talks to Postgres over a direct connection string (an ORM like Prisma or Drizzle, or psql), it doesn't affect you.
Am I affected?
- Yes, if your app reads or writes
publictables withsupabase-js, another Supabase client library, or plain HTTP to/rest/v1/or/graphql/v1. - Yes, if your migrations, or your AI tool, create tables without
grantstatements and expect the app to see them right away. - Yes, server code too. An Edge Function or API route that uses the
service_rolekey still goes through the Data API. That key skips RLS, but it doesn't skip grants, so it gets the same 42501 on a new table with no grant. - No, for tables that already exist when the change reaches your project, and for tables in the
auth,storage,realtimeor your own custom schemas.
Step 0: make sure it's a grant problem and not RLS
Supabase uses the code 42501 for more than one problem, so read the message, not just the code.
| What you see | What it means | Fix |
|---|---|---|
42501 with permission denied for table ... | The role has no grant on the table. Postgres stops the query before RLS even runs. | This guide: add the grant. |
42501 with new row violates row-level security policy | The grant is fine, but the insert or update fails the policy's with check. | Fix the policy or set user_id. See our Supabase auth and RLS guide. |
Empty array [], no error | The grant is fine and RLS is on, but no select policy matches this user. | Add a select policy. Same guide. |
401 or Invalid API key | Wrong or missing key in production. | Check your production environment variables. |
The hint in the error is useful. It names the role that's missing access (anon for logged-out visitors, authenticated for logged-in users) and the privilege it needs.
See which tables are missing grants
Open the SQL Editor in your Supabase dashboard and run this read-only query. It lists every table and view in public with what each API role can do and whether RLS is on:
select c.relname as table_name,
has_table_privilege('anon', c.oid, 'select') as anon_select,
has_table_privilege('authenticated', c.oid, 'select') as authed_select,
has_table_privilege('authenticated', c.oid, 'insert') as authed_insert,
has_table_privilege('service_role', c.oid, 'select') as service_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.relkind in ('r', 'p', 'v', 'm')
order by 1;
A table your app uses that shows false for the role making the request is your culprit. Supabase's Security Advisor also flags affected tables and shows the SQL to fix them, and the Table Editor shows a Data API exposure badge per table.
The fix: grant, enable RLS, add policies, together
Supabase's own advice is to treat these three steps as one unit, in the same migration. Here is the pattern for a table of per-user rows, like notes:
-- 1. Grant only what each role needs
grant select, insert, update, delete on public.notes to authenticated;
grant select, insert, update, delete on public.notes to service_role;
-- (no grant to anon: logged-out visitors should not touch this table)
-- 2. Turn on Row Level Security
alter table public.notes enable row level security;
-- 3. Say which rows each user may touch
create policy "read own notes" on public.notes
for select to authenticated using ((select auth.uid()) = user_id);
create policy "add own notes" on public.notes
for insert to authenticated with check ((select auth.uid()) = user_id);
create policy "edit own notes" on public.notes
for update to authenticated
using ((select auth.uid()) = user_id) with check ((select auth.uid()) = user_id);
create policy "delete own notes" on public.notes
for delete to authenticated using ((select auth.uid()) = user_id);
For a table that anyone may read, such as public blog posts or a product list, add grant select on public.posts to anon; plus a select policy for anon, and nothing more. Logged-out visitors almost never need insert, update or delete.
If the table uses a serial or bigserial id, inserts also need the sequence: grant usage, select on sequence public.notes_id_seq to authenticated;. Tables with generated ... as identity ids, the Supabase default, don't need this.
Put the SQL in a migration file (for example in supabase/migrations/) rather than only running it in the SQL Editor, so the next environment or the next rebuild gets the same grants.
What not to do
- Don't
grant alltoanonto make the error go away. That gives every visitor with your public key full access to the table, limited only by RLS. - Don't disable RLS as a fix. A grant with RLS off exposes every row to every role you granted.
- Be careful with bulk grants.
grant ... on all tables in schema publicis in Supabase's rollback FAQ for projects that opted in early and broke, but it also re-exposes tables you meant to keep private. Run the query above first, and revoke private tables afterwards. - Don't move the call to the
service_rolekey in the browser. That key must never ship in frontend code, and as shown above it needs grants anyway.
Lovable, Bolt and other AI builders
The table usually comes from a migration the AI wrote. Open the migration that created the table and check whether it has grant lines next to the enable row level security line. If it doesn't, add a new migration with the grants rather than editing an old migration that has already run. Supabase also recommends updating your AI tool's instructions, or using its agent skill, so new tables always get grants.
If your app uses a Supabase project the builder manages for you, check that platform's docs for how it handles the new default before writing SQL by hand.
Want all three dated checks (Oct 30 grants, Nov 19 model, legacy keys) at once? Run the one free check.
Free check: will your migrations still work after October 30?
Paste a public GitHub repo. Your browser reads the SQL files in supabase/migrations through the GitHub API and lists every table created in public with no grant statement, and every table with no RLS. Nothing is sent to VibeRescue and nothing is stored.
Prepare before October 30
- List the tables your app uses and run the query above. Anything your app needs should already show the right grants. Existing tables keep theirs.
- Add
grantstatements to every migration or prompt that creates tables from now on. - Optional: test the new behavior early. Supabase documents a way to opt in on an existing project with
alter default privileges ... revoke, and a rollback in the same changelog. Try it on a staging or branch project first, not production. - After October 30, create a test table and confirm your app's flow still works the first time a new table appears.
How to prompt your AI tool for this fix
Supabase returns 42501 "permission denied for table [table]" for the
[anon / authenticated] role. Do not disable RLS and do not grant all to anon.
Write one new migration that grants only the privileges this feature needs
to authenticated (and to anon only if logged-out users must read it),
grants the same to service_role, keeps RLS enabled, and adds policies that
limit rows to (select auth.uid()) = user_id. Show me the full SQL first.
A tightly scoped prompt keeps the tool from "fixing" the error by opening the table to everyone. If it keeps going in circles, here's how to break the AI fix loop.
FAQ
Why do I get "permission denied for table" on a new Supabase table?
From October 30, 2026, Supabase no longer grants the anon, authenticated and service_role roles access to new tables in the public schema of existing projects. Until you add an explicit GRANT for the role making the request, the Data API refuses the query with error 42501.
Are my existing Supabase tables affected by the October 30 change?
No. Tables that already exist when the change reaches your project keep their current grants and stay reachable. Only tables created afterwards need explicit GRANT statements.
Is 42501 an RLS error or a grant error?
Both use code 42501, so read the message. "permission denied for table" means the role has no grant on the table. "new row violates row-level security policy" means the grant is fine but the row fails a policy check.
Does the service_role key bypass the missing grant?
No. The service_role key bypasses Row Level Security, but it still needs a table grant when it goes through the Data API, so Edge Functions and API routes that use it get the same error on new tables.
Should I just grant all privileges to anon to fix it?
No. Grant only what each role needs, keep RLS enabled and add policies in the same migration. Logged-out visitors usually need select on public tables at most.