← Blog · 29 October 2026
"Permission denied for table" (42501) in your Lovable or Supabase app? The safe fix after Supabase's October 30 change
Start with the outside check: paste your app's address into the free Vibe-App Watchdog scan. It looks at what any visitor can see, like secret keys in your public JavaScript, open files such as /.env, and missing security headers. It cannot see your database grants or Row Level Security, so the steps below are ones you do yourself in Supabase.
You asked Lovable, Bolt or Cursor for a new feature. It made a new table, the code looks fine, but the page won't load or won't save. In the browser console you see:
{ "code": "42501", "message": "permission denied for table your_table" }
Often nothing is broken in your code. Supabase is changing a default.
What changes on October 30, 2026
Supabase announced it in its changelog on April 28, 2026 (Supabase discussion #45329: "Tables not exposed to Data and GraphQL API automatically"):
- Until now, every new table in the
publicschema automatically gotselect,insert,updateanddeleterights for theanon,authenticatedandservice_roleroles. That made it reachable through the Data API (the API thatsupabase-jsand your frontend call) the moment it was created. - New projects got the new behaviour from May 30, 2026. Supabase says that on October 30, 2026 it will be applied to all existing projects.
- Once the change reaches your project, a new table needs an explicit
GRANTbefore the Data API can see it. Existing tables keep their current rights and keep working. - If your app talks to Postgres over a direct connection string (an ORM or your own server), you are not affected.
Supabase's own error hint even suggests the fix: GRANT SELECT ON public.your_table TO anon;. That hint is correct about what is missing. It is not always what you want to run.
Grants and RLS are two different locks
- A grant decides whether a role (
anon= logged-out visitors,authenticated= logged-in users) can touch a table at all. - Row Level Security (RLS) decides which rows that role can see or change.
Supabase says RLS behaviour does not change with this update. But the order matters: your anon key is in your frontend on purpose, and Supabase's docs say a table in an exposed schema without RLS is readable and writable by any role with a grant on it (Supabase: Row Level Security). So if you add a grant to a table that has RLS turned off, you have just made that table public.
The fix you should not paste
A tempting quick fix is:
grant all on all tables in schema public to anon, authenticated;
Don't. It hits every table at once, including any table where RLS is off, and it gives logged-out visitors rights they usually do not need. The new default is a good safety net. Open only the tables you mean to open, one at a time.
The safe fix, step by step
Do this in the Supabase dashboard under SQL Editor. Replace your_table with your table name, and user_id with the column that holds the owner's id.
1. Turn on RLS first.
alter table public.your_table enable row level security;
2. Add a policy so users only reach their own rows.
create policy "owner can read and write"
on public.your_table
for all
to authenticated
using (user_id = (select auth.uid()))
with check (user_id = (select auth.uid()));
3. Grant only what logged-in users need.
grant select, insert, update, delete on public.your_table to authenticated;
4. Only if logged-out visitors must see this table (for example a public list of products), add read access for anon, and nothing more:
grant select on public.your_table to anon;
Then add a matching for select to anon policy that only returns the rows that are meant to be public.
5. Server code. If an Edge Function uses the service_role key on this table, give that role access too: grant select, insert, update, delete on public.your_table to service_role;. That key skips RLS, so it must never be in your frontend.
Tell your AI builder once, so you don't fix this every time
Add a line like this to your project's instructions (in Lovable: project knowledge):
When you create a new table in Supabase: enable Row Level Security, add policies so users only reach their own rows, then grant only the needed rights to
authenticated. Grantselecttoanononly if I say the table is public. Never usegrant all.
Check it worked
Only test your own app and your own Supabase project, with your own test accounts.
- Logged in: the feature loads and saves again.
- Logged out: open your app in a private window. In DevTools, open Network and look for requests to
/rest/v1/your_table. A table that should be private must not return rows. - Run Supabase's Security Advisor (Advisors > Security Advisor) and fix any "RLS disabled" warning on tables in
public. - Check what the live site shows the world: run the free outside scan on your published address. It catches the other common leaks, like a
service_roleor Stripe secret key in your JavaScript or a public/.envfile. It does not test grants or RLS, which is why steps 1 to 3 matter.
Quick answers
Are my old tables affected? No. Supabase says existing tables keep their current grants. Only tables created after the change reaches your project need a grant.
Does this change make my app less secure? No. Supabase describes it as keeping new tables closed until you open them. The bigger risk is a rushed fix like grant all.
I use Lovable Cloud, not my own Supabase project. Does this apply? We have not found a statement from Lovable about whether or when this applies to Lovable Cloud. If you see the 42501 error, the same fix applies.
Will the free scan find this? No. The scan only sees what a visitor's browser can load. It cannot read your database rules. Use the logged-out test and Supabase's Security Advisor for that.