New row violates row-level security policy fix in Supabase: ERROR 42501 on insert, then user_id default auth.uid(), INSERT with check, SELECT and UPDATE for select and upsert, storage upload 200 OK

New Row Violates Row-Level Security Policy? Fix It (2026)

You click Save in your app and nothing happens. The console shows code: 42501 and the message new row violates row-level security policy for table “notes”. Reads work, sign-in works, but every insert, upsert or file upload fails. If your app was built with Lovable, Bolt, v0 or Cursor on Supabase, the causes and fixes below are the same.

The good news: it is almost never a bug in Supabase. Postgres is doing exactly what Row Level Security (RLS) is for. The row you are trying to write does not pass a WITH CHECK rule, or no rule allows that write at all. This guide shows how to find which one, with copy-paste SQL for each case. If your problem is users seeing each other’s data instead, read Supabase RLS not working. If the error says permission denied for table, read Supabase permission denied for table.

Quick answer: The insert is running as a role that no INSERT policy allows, or the new row fails the policy’s WITH CHECK. Sign the user in before writing, set user_id with default auth.uid(), add an INSERT policy to authenticated with check ((select auth.uid()) = user_id), and add SELECT (plus UPDATE for upsert) policies when you chain .select() or upsert.

What you seeMost likely causeCheckFix
.insert() fails while signed inNo INSERT policy, or user_id missing so the check compares to nullDoes the payload or column default set user_id?Add INSERT policy, set default auth.uid()
Fails when signed out or on first page loadRequest runs as anon, so auth.uid() is nullCall supabase.auth.getUser() right before the insertWait for the session, require sign-in
.insert() works, .insert().select() failsNo SELECT policy that matches the new rowList policies in pg_policiesAdd a SELECT policy for the owner
.upsert() fails, .insert() worksUpsert also needs SELECT and UPDATE policiesAre SELECT and UPDATE policies present?Add SELECT + UPDATE with the same owner check
.update() throws the same errorUPDATE WITH CHECK rejects the changed rowIs the code changing user_id?Keep user_id, add USING + WITH CHECK
Storage upload returns 403No INSERT policy on storage.objects, or wrong folderBucket id and file path vs the policyAdd storage policies, upload to userId/file
Server code with the secret key still failsA user session took over the Authorization headerSSR client or signUp on the admin client?Use a separate admin client
permission denied for table insteadMissing grant, not a policyQuery role_table_grantsSee permission denied fix

Want it fixed for you? Launch Mango moves your Lovable, Bolt, v0 or Cursor app onto your own GitHub, Supabase and Vercel accounts and makes it safe for real users. Own and Secure is $199 one-off: everything in Own Your App plus sign-in and redirects, Supabase RLS and permissions locked down, exposed API keys removed, live Stripe payments and webhooks, a security report and your custom domain included. Not sure where your app stands? Run the free 2-minute app check.

What Does “New Row Violates Row-Level Security Policy” Mean?

It means Postgres refused to write a row because Row Level Security is on for that table and the new r