On this page 6 sections
Supabase permission denied for table (error 42501) on a table you just created means the table has no grants. Since October 30, 2026, Supabase no longer grants new public tables to its API roles automatically. Fix it with three GRANT statements per table, keep row level security on, then add a rule so your AI builder stops repeating it.
That’s the whole diagnosis for most founders who landed here. A feature your Lovable, Bolt or Cursor agent built last week worked. Today the agent added a table for the next feature, and that screen shows nothing, or an error toast, or a 401 or 403 in the network tab. Nothing in your code changed. Supabase’s defaults did.
Why Supabase permission denied for table appears
Until this year, every new table in the public schema was automatically granted select, insert, update and delete for the anon, authenticated and service_role roles. That meant any table your agent created was reachable through the Data API the moment it existed. Supabase’s changelog on the breaking change lays out the switch in three dates:
- April 28, 2026: new projects could opt out of automatic exposure.
- May 30, 2026: opting out became the default for new projects.
- October 30, 2026: the new behavior applied to all existing projects.
Now a new table is reachable through the Data API only after an explicit GRANT. Supabase says existing tables are not affected and keep their current grants, so the break shows up only on tables created after the change. That’s why it looks random: the old screens work and the new one doesn’t.
The API response tells you exactly what’s missing. Per the same changelog, it returns code 42501, the message permission denied for table your_table, and a hint naming the role and the GRANT you need. Supabase’s 42501 troubleshooting page adds that this Postgres code usually reaches your app as a 401 or 403, which is why an agent reading only the status code often blames your login flow instead.
A missing grant fails loudly, RLS quietly
Your project has two locks on every table, and AI builders tend to mix them up. Supabase’s guide to securing your API puts it in two sentences: grants control whether a role can access an object; row level security (RLS) controls which rows the role can access.
The two fail differently:
- No grant: the request is refused outright with
permission denied for table. Postgres stops at the grant check, so none of your RLS policies are ever read. - Grant, RLS on, no matching policy: reads succeed and return an empty list. The Supabase RLS guide says that once RLS is enabled, no data is accessible with the publishable key until you create policies. Inserts without a policy fail with the same 42501 code but a different message:
new row violates row-level security policy.
This is where agents make the bug worse. Asked to fix a 42501, an agent will often write more policies (which can’t help, because the grant check comes first) or turn RLS off (which doesn’t clear the error and leaves the table unprotected once the grant lands). If the message says permission denied for table, it’s a grant. If the data comes back empty, it’s a policy, and our guide to why Supabase row level security fails walks through those six causes.
The three-line fix for each table
Run this in the SQL editor for each new table, or better, add it to the migration that created the table. These are the grants Supabase’s changelog recommends:
grant select on public.bookings to anon;
grant select, insert, update, delete on public.bookings to authenticated;
grant select, insert, update, delete on public.bookings to service_role;
alter table public.bookings enable row level security;
Then write the policies the feature needs. Three adjustments make this safer than copying it blindly:
- Drop the
anonline if logged-out visitors never read the table. A grant is permission to try. Least privilege means granting only the verbs each role uses, so a policy written too broadly later can’t expose the table to anyone with your public key. - Check what a table has. Supabase’s troubleshooting page gives the query:
select grantee, privilege_type from information_schema.role_table_grants where table_name = 'bookings';An empty result foranonandauthenticatedconfirms the diagnosis. - Watch for the second error. If inserts then fail with
permission denied for sequence, the table uses a serial id. Postgres’s privileges reference saysUSAGEon a sequence allowsnextval, so grantusageon that sequence to the roles that insert rows.
Views and functions follow their own rules. Views need their own grants, and the securing-your-API page notes that new functions stay callable by every role because Postgres grants execute to PUBLIC globally. If an RLS policy calls a helper function, make sure the roles can execute it.
One shortcut to avoid: Supabase’s Data API settings still let you expose new tables automatically. Switching that back on makes the error disappear and brings back the old default, where every table your agent creates is open to the API before anyone has written a policy for it.
Stop your AI builder from repeating it
Fixing today’s table takes a minute. The next feature will create another table, and the agent will skip the grants again unless something tells it not to. Commenters in Supabase’s discussion of the change report the same pattern: AI-generated migrations often leave out GRANT statements. Supabase staff in that thread call explicit grants in migrations the durable approach.
So write it down where the agent reads it on every change:
- Lovable: per Lovable’s instructions docs, it reads any
AGENTS.mdorCLAUDE.mdfile at the top level of your project with every message you send. Project settings also has an Instructions field, up to 10,000 characters. - Cursor: Cursor’s rules docs say it supports
AGENTS.mdin the project root, and project rules live in.cursor/rulesas.mdcfiles. SetalwaysApply: true, or scope the rule withglobsto yoursupabase/migrationsfolder. - Bolt and other builders: put the same text in whatever project prompt or instructions field the tool gives you, and keep a copy in
AGENTS.mdin the repo so it travels with the code.
The rule itself, ready to paste:
Supabase: every migration that creates a table in public must, in the same file,
1. grant only the needed privileges to anon, authenticated and service_role,
2. enable row level security,
3. create the policies the feature needs.
Never disable RLS or use the service role key in client code to fix a
permission error. "permission denied for table" means a missing grant.
Then check it held. After each feature, call the new table from the app as a logged-out visitor and as a signed-in user. One request each is enough to catch a missing grant before your users do.
Which fix fits your situation
| What you see | Cause | Fix |
|---|---|---|
permission denied for table on a table created after October 30 | No grant | Grant per role, enable RLS, add policies |
| Same error after a restore, reset or recreated table | Grants didn’t survive | Put grants in the migration that creates the table |
| Empty list, no error | Grant present, no matching policy | Write a SELECT policy for the right role |
new row violates row-level security policy | Insert blocked by RLS | Add or fix the INSERT policy’s check |
permission denied for sequence on insert | Serial id without sequence grant | Grant usage on the sequence |
| The agent keeps breaking new tables | No standing rule | Add the rule to AGENTS.md or project rules |
If more than two rows apply, the problem is the migration history, not one table. That’s usually the moment to have a developer read the whole schema once. Our migrating off Lovable Cloud guide covers checking grants table by table after a move between projects.
WordUp Tutoring: from one build to a retainer
We built WordUp Tutoring’s learning app on Next.js and Supabase: daily challenges, homework help, reading support and learning games for K-8 students, with sign-in by email or Google and a separate way in for students. After that first fixed-scope build, WordUp moved to a retainer, and our engineer has kept building the AI into the product since.
A product that keeps growing keeps adding tables, which is the exact spot this change bites. Every new feature on a live Supabase app is a new table, a new set of grants and a new set of policies, written together and reviewed together. On a codebase a person owns, that’s a habit. On one an agent writes, it has to be a rule.
When an AI-built app has already collected a few of these breaks, our Code Rescue engagement is where we fix them: grants, RLS and migrations on a Lovable, Bolt or Cursor codebase, so the next feature doesn’t undo the last one. It runs 2-4 weeks. Code Rescue starts at $6,000. If your app came from one of those builders, the fixes by tool page shows what we usually find in each.
Frequently asked questions
- Why does Supabase say permission denied for table on a table I just created?
- The table has no grants for the API roles. Since October 30, 2026, Supabase no longer grants new tables in the public schema to anon, authenticated and service_role on any project, so the Data API refuses every request with error 42501. Grant the privileges each role needs, enable row level security, and add your policies in the same migration.
- Will disabling row level security fix Supabase error 42501?
- No. Postgres checks table grants before row level security, so a request without a grant fails before any policy is read. Turning RLS off leaves the error in place and removes your row protection for the moment you do add the grant. Add the grant instead, and keep RLS enabled on every table the Data API can reach.
- Are my existing Supabase tables affected by the October 30 grants change?
- Supabase says no: tables that existed before the change keep their current grants and stay reachable through the Data API. The change applies to tables created after it. A table that is dropped and recreated, or rebuilt by a restore or a database reset, counts as new and needs its grants added again in the migration that creates it.
- Why do I get permission denied for sequence after fixing the table?
- The table uses a serial id, and inserting a row calls nextval on the sequence behind it. In Postgres, nextval needs the USAGE or UPDATE privilege on that sequence, which a table grant doesn't include. Grant usage on the sequence to the roles that insert rows, or use a uuid or identity primary key for new tables.
- How do I stop Lovable or Cursor from creating Supabase tables without grants?
- Put a rule in a project instructions file that the agent reads on every change. Lovable reads AGENTS.md or CLAUDE.md at the top of your project with every message, and Cursor reads AGENTS.md and .cursor/rules files. The rule should require grants, row level security and policies in the same migration as every new table.
References
- Supabase changelog - Tables not exposed to Data and GraphQL API automatically
- Supabase - Securing your API
- Supabase - Database API 42501 errors
- Supabase - Row Level Security
- Supabase GitHub discussion #45329 - tables not exposed automatically
- PostgreSQL - Privileges
- Lovable - Instructions and AGENTS.md
- Cursor - Rules