ErrorsPostgres

42501

Row-level security blocked the write

The database refused an insert, update or delete because no policy allows this visitor to perform it on that row.

Why it happens

In an AI-built app, specifically

Row-level security was switched on — correctly — but only a read policy was written. Reads work, so the app looks healthy, and then the first save fails. It also happens when an INSERT policy checks a column the app does not set, such as a `user_id` the code expects the database to fill in.

What it is not: Not a login problem. The user is signed in — the database simply has no rule permitting what they tried.

Steps

How to fix it

  1. 01Open the table's policies and check there is one for the operation that failed. A SELECT policy does not permit INSERT.
  2. 02If an INSERT policy exists, read its WITH CHECK clause. It has to be satisfiable by the row your app is actually sending.
  3. 03If the policy expects a `user_id` matching the signed-in user, confirm your app sets that column rather than leaving the database to guess.
Still stuck

If the steps did not do it

An error is one symptom, and the cause is often somewhere else entirely. The broken-app check reads your published site and looks at everything at once — and if it cannot tell either, connecting your repository is what lets Refinar read the code and fix it.

Got feedback that's been waiting for weeks? Ship it today.