Supabase 'New Row Violates Row-Level Security Policy' Error

Workaround available Web, server (all SDKs) Updated October 21, 2026

Quick answer

RLS is on but no policy allows the write. Add an INSERT (or UPDATE) policy with a WITH CHECK that matches the row, plus a SELECT policy if you return the inserted row.

Most likely fix: Add an INSERT policy.

Symptoms

Insert or update fails with 'new row violates row-level security policy for table ...' (code 42501), or queries return empty arrays even though data exists.

Why it happens

  • Only a SELECT policy exists - writes need their own INSERT/UPDATE policy
  • Request is anonymous so auth.uid() is null
  • Row payload doesn't include the column the policy checks (e.g. user_id)
  • .insert().select() needs a SELECT policy to return the row
  • Storage upload with upsert needs UPDATE policy too

How to fix it

Try these in order — the most common fix is first.

  1. 1. Add an INSERT policy

    1. Dashboard > Authentication > Policies > select table
    2. New policy > For INSERT, target role authenticated
    3. WITH CHECK: auth.uid() = user_id
  2. 2. Make sure the user is signed in

    1. Check supabase.auth.getUser() returns a user before writing
    2. Server-side, create the client with the user's session cookies, not the anon key alone
  3. 3. Send the column the policy checks

    1. Include user_id in the insert payload or set a default of auth.uid() on the column
  4. 4. Add a SELECT policy for returned rows

    1. If you call .insert().select() or .upsert(), add a SELECT policy allowing the user to read their own rows
  5. 5. Test as the real role

    1. SQL Editor runs as postgres and bypasses RLS
    2. Use the role switcher in the SQL editor to impersonate an authenticated user

This guide also covers

  • new row violates row-level security policy supabase
  • supabase rls not working
  • supabase insert rls error
  • supabase 42501

Still not working?

If Supabase keeps failing, you're not alone. See every Supabase problem users report or the alternatives people switch to.

Other Supabase errors