new row violates row-level security policy for table
- Supabase
- Postgres
What it means
Row Level Security is on, and no policy allows this particular row to be added or saved. Usually there is no INSERT policy, or the row's owner column is not set to the signed-in user.
Why it happens
- There is no INSERT (or UPDATE) policy on the table, only a SELECT one.
- The insert does not set the owner column, so the policy's check (auth.uid() = user_id) fails.
- The request is made by a visitor who is not signed in.
How to fix it
- Add an insert policy: create policy "insert own" on public.your_table for insert to authenticated with check ((select auth.uid()) = user_id);
- Set the owner automatically: give user_id a default of auth.uid(), or set it in the insert.
- Make sure the user is signed in when the insert runs.
- Never switch RLS off to make the error go away.
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 'new row violates row-level security policy' from Supabase on an insert. Without changing anything yet, show me the insert code, the table's RLS policies, and which column identifies the owner. Tell me which policy should allow this row and why it does not. Do not suggest disabling RLS.