Paul Milliken

Error guide

new row violates row-level security policy

What it means

Your app reached the database, but the database refused to save the row. Row-level security is on for that table, and no rule allows this user to add this row.

Check these, in order

  1. Is there a rule for adding rows? Rules for viewing, editing and deleting don't cover adding. On Lovable Cloud: More → Database, click the table, then RLS policies. On your own Supabase project: Database → Policies. Look for a policy for INSERT on that table.
  2. Does the rule match the row you send? Most rules say the row's owner column (often user_id) must equal the signed-in user's id. If the app sends no user_id, or a different one, the rule refuses it.
  3. Is the user signed in when it saves? A rule for signed-in users doesn't apply to a request sent before sign-in finishes or after the session ends.

Don't fix it by turning row-level security off, or by adding a rule that allows everyone. That makes every user's rows open to everyone.

Practice app: in one of my practice apps, where I planted this fault to test my checks, the notes table had rules for viewing, editing and deleting notes, but none for adding one, so every new note was refused. The fix was one added rule: signed-in users may add notes only under their own user id.

Still stuck? Send me the app

I'll show you what's wrong, on video, within 24 hours. Free.

Free. No call. If I can't find the cause, I'll tell you so.

Please don't put passwords or keys in the form.