Your app worked yesterday. Then you (or your AI builder) added a new table, and every request to it fails with something like this:
{
"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 older tables still load fine. Only the new one breaks.
This is expected behaviour, not a bug in your code. Supabase changed a long-standing default, and the change reached all existing projects on October 30, 2026. This guide explains what changed, how to tell this error apart from a row-level security (RLS) failure, and the SQL that fixes it without opening your data to everyone.
What Supabase changed on October 30, 2026
Until recently, three roles got read and write access (select, insert, update, delete) to every new table in the public schema without you asking: anon (signed-out visitors), authenticated (signed-in users) and service_role (trusted server code). That made a new table reachable through Supabase’s Data API the moment it existed.
Supabase announced in April 2026 that it would stop doing this. The rollout went in stages: an opt-in setting first, then the new behaviour as the default for new projects from May 30, 2026, and then for all existing projects on October 30, 2026 (Supabase changelog: tables not exposed to the Data API automatically).
Now, a new table in public exists but can’t be reached through the Data API until you grant access with a Postgres GRANT statement. A few details from that announcement matter:
- Existing tables aren’t touched. Tables created before the change keep their grants, so the parts of your app that already worked keep working.
- It only affects the Data API. That’s the REST and GraphQL layer that
supabase-jsand the other client libraries call. If your server talks to Postgres over a direct connection (an ORM,psqlor a connection string), you aren’t affected. - It only affects the
publicschema. Tables inauth,storage,realtimeand your own custom schemas keep their current behaviour. - It doesn’t matter how the table was made. The SQL editor, a migration, the CLI, the Management API or an AI coding tool all get the same result.
- RLS works the same as before. Grants and policies are separate layers.
Supabase’s reason is security: with automatic grants, a table could be exposed before anyone had protected it, and AI tools and scripts now create tables with no human checking the change.
Is it a missing grant or an RLS policy?
Both problems can come with the code 42501, so read the message, not just the number.
- “permission denied for table …” means the role has no grant on the table. Postgres refuses the request before RLS is even checked. Supabase’s RLS docs say a missing grant “raises a
42501error before any policy runs” (Supabase RLS docs). This is the error this guide fixes. - “new row violates row-level security policy …” means the grant is fine and a policy rejected the row. That’s a different fix, covered in our guide to the Supabase “new row violates row-level security policy” error.
- No error, but an empty list can mean RLS is on and no policy lets this user see those rows. Policies hide rows quietly instead of failing.
The hint in the error is useful. It names the role that was refused (anon or authenticated) and the privilege it was missing. A role of anon tells you the request was made while signed out.
How to fix it: grant, enable RLS, add policies
Supabase’s advice is to treat three steps as one unit and put them in the same migration as the create table: grant the privileges each role needs, turn on RLS, and add policies.
Here is a version for a table where each signed-in user owns their own rows through a user_id column. Replace public.notes with your table, and check that the owner column name matches.
-- 1. Grants: who can run which operations at all
grant select, insert, update, delete on table public.notes to authenticated;
grant select, insert, update, delete on table public.notes to service_role;
-- No grant for anon: signed-out visitors get nothing.
-- 2. Row level security
alter table public.notes enable row level security;
-- 3. Policies: which rows each operation applies to
create policy "Owners can read their notes"
on public.notes for select
to authenticated
using ( (select auth.uid()) = user_id );
create policy "Owners can add their notes"
on public.notes for insert
to authenticated
with check ( (select auth.uid()) = user_id );
Add update and delete policies the same way if your app edits or removes rows. Our Supabase RLS policies guide has the full set with explanations.
Grant each role only what it needs
The point of the change is that access is now a choice you write down. Use it:
authenticatedgets the operations your signed-in screens actually perform. A read-only feed only needsselect.anongets a grant only if signed-out visitors are meant to use the table, and for public content such as a list of published posts that meansselectonly. Supabase’s own example grantsanonselect only.service_roleis for trusted server code like Edge Functions and webhooks. It bypasses RLS, so its key must never be in the browser.
If inserts still fail: the ID sequence
If your table uses an auto-incrementing number column (serial or bigserial), inserting a row needs the next number from a sequence, and in Postgres the role needs USAGE or UPDATE privilege on that sequence (PostgreSQL sequence functions). The revoke SQL in Supabase’s announcement covers sequences as well as tables. If the error says “permission denied for sequence”, grant it to the roles that insert:
grant usage, select on sequence public.notes_id_seq to authenticated;
Tables that use a uuid primary key with a default value don’t need this step.
Fixing it in Lovable, Bolt and other AI builders
When an AI tool creates a table and the app then fails with this error, the tool skipped the grant. Supabase says its agent skill includes the grants step and is kept updated as the platform changes, and that agents can correct themselves using the hint in the error. You still need to check what they write.
A prompt you can adapt:
The new table
notesfails with Supabase error 42501 “permission denied for table”. Write one migration that grants select, insert, update and delete onpublic.notestoauthenticatedonly, enables row level security, and adds owner-only policies usingauth.uid() = user_id. Don’t grant anything toanon. Show me the SQL before applying it.
Then read the SQL before you approve it. Push back if you see:
grant ... to anonon a table that holds private dataon all tables in schema public, which grants every table at oncealter table ... disable row level security- a policy with
using (true)orwith check (true)on private data
To stop it happening again, add a standing rule to your project’s instructions or knowledge file: every new table in public gets explicit grants, RLS and policies in the same migration.
Shortcuts to avoid
- Don’t bulk-grant every table to
anonandauthenticated. Supabase documents a bulk grant for rolling back the change, but it reopens every table inpublic, including ones you meant to keep private. Grant table by table instead. - Don’t switch off RLS to make the error go away. Supabase’s docs warn that a table in an exposed schema without RLS “is readable and writable by any role with a grant on it”. Adding a grant to a table with RLS off exposes all of it.
- Don’t route around it with the service role key in the frontend. It skips RLS completely, and anything in the browser can be copied.
Check your other new tables
The first broken table may not be the only one. Any other table created in public after October 30 has the same gap. Supabase’s announcement says the Security Advisor flags affected tables and shows the SQL to fix them, and the Table Editor shows a Data API exposure badge for each table. Go through both, and for each table decide which roles really need it.
It’s also a good moment to check the opposite problem. Tables created before the change still carry the old automatic grants for anon and authenticated. Supabase’s RLS docs point out that adding policies doesn’t take those grants back. If an older table shouldn’t be reachable by signed-out visitors, revoke the grant and rely on our security checklist for vibe-coded apps for the rest.
If you’d rather have someone go through every table, grant and policy for you, inahei.pro connects you with vetted senior engineers who fix and secure apps built with AI tools, and explain what they changed. Fixed price, agreed upfront. See /fix/supabase.
FAQ
Why does only my new table fail when the old ones still work?
Because the change applies to tables created after it reached your project. Tables that existed before October 30, 2026 kept their automatic grants. New tables in public start with no grants for anon, authenticated or service_role, so the Data API refuses them until you add grants.
Is 42501 always a missing grant?
No. Postgres uses 42501 for “insufficient privilege” in general, and Supabase returns it for RLS rejections too. If the message says “permission denied for table”, it’s a grant. If it says “new row violates row-level security policy”, it’s a policy.
Do I need to grant anything to anon?
Only if signed-out visitors should use that table, and then only select on public data. If every screen that uses the table requires sign-in, leave anon out.
My app connects through Prisma or another ORM. Am I affected?
Not by this change, if the ORM uses a direct Postgres connection. Supabase says the change only affects the Data API, which is what supabase-js and the other client libraries use. Some apps use both, so check how each part of your app reaches the database.
Can I turn the old automatic grants back on?
Supabase documents SQL to restore the old defaults. It’s meant as a rollback, and it brings back the original risk that a new table is open before anyone secures it. Explicit grants in each migration are the safer habit.
Comments