permission denied for table
- Supabase
- Postgres
What it means
The database refused before checking any row: the role your app uses (anon or authenticated) has no permission to use this table at all. Row Level Security never got a chance to run.
Why it happens
- The table was created with SQL and the anon or authenticated role was never granted access to it.
- A grant was revoked, often while someone (or an AI) was 'fixing' security.
- The table lives in a schema your API roles cannot use.
How to fix it
- Grant only what the app needs, for example: grant select, insert, update, delete on public.your_table to authenticated;
- Keep Row Level Security on, with policies that limit each user to their own rows.
- Do not fix this by disabling RLS or granting everything to anon: that turns a locked table into a public one.
Let your AI find the cause
Paste this into Claude Code, Cursor, Lovable or whichever AI built your app. It looks first and changes nothing until you have read the answer.
My app gets 'permission denied for table' from Supabase. Without changing anything yet, find the table in the error, show me the SQL or migration that created it, and list which roles (anon, authenticated) have grants on it and which RLS policies it has. Then propose the smallest grant that fixes it while keeping Row Level Security on.