All guidesSupabase RLS and keys
On this page

Supabase Storage error

Supabase Storage upload fails with "new row violates row-level security policy" or "must be owner of table objects": the fix

By Ohad Krispin, founder of VibeRaven · LinkedIn

Short answer

"new row violates row-level security policy" on a Supabase Storage upload means no policy on storage.objects lets this user insert this file: row level security is on for that table by default, and Supabase says Storage allows no uploads without a policy. Add an INSERT policy for the bucket, usually limited to a folder named after the user's ID, plus SELECT and UPDATE policies if you upload with upsert. "must be owner of table objects" comes from a migration that runs alter table storage.objects, which agents still write: the table belongs to supabase_storage_admin and RLS is already on, so delete that line and keep only the create policy statements.

Supabase Postgres 17.11 and Storage API v1.79.28 run locally: altering storage.objects fails with must be owner of table objects; an upload with no policy returns new row violates row-level security policy, and succeeds after an INSERT policy.
Supabase Postgres 17.11 and Storage API v1.79.28 run locally: altering storage.objects fails with must be owner of table objects; an upload with no policy returns new row violates row-level security policy, and succeeds after an INSERT policy.

The INSERT policy for per-user folders

Upload each user's files under a folder named after their ID, such as avatars/<user id>/avatar.png, and check that folder in the policy. storage.foldername(name) returns the path's folders as an array, so [1] is the first one:

SQL
create policy "Users upload to their own folder"
on storage.objects for insert to authenticated
with check (
  bucket_id = 'avatars'
  and (storage.foldername(name))[1] = (select auth.uid()::text)
);

Upsert fails even though insert works

Supabase's docs say overwriting with upsert also needs SELECT and UPDATE. Add both with the same bucket and folder check as the INSERT policy, or the upsert fails with the same message, new path or not.

must be owner of table objects

The same error appears for disable row level security or any alter table on storage.objects. The storage tables belong to supabase_storage_admin, and Supabase has blocked changes to them since 2025-04-21. Its announcement of that restriction still allows creating RLS policies and triggers on storage.objects, and its docs ask you to treat the storage schema as read-only. Remove the alter line from the migration; if the migration already ran on the project, the advice in supabase/cli issue 4114 is to mark it applied with supabase migration repair --status applied and the migration's version.

Does a public bucket fix it?

No. Supabase's docs say a public bucket only skips access control for downloading files; uploading, deleting, moving and copying are still checked. Buckets are private by default. The service role key skips RLS altogether, so keep it on the server and never use it to make browser uploads work.

Make uploads work without opening the bucket

  1. 1
    Delete any alter table storage.objects line from your migrations.
  2. 2
    Pick the path layout, such as <bucket>/<user id>/<file name>, and upload to it from the client with the signed-in user's session.
  3. 3
    Create the INSERT policy for your bucket, in a migration or the SQL editor.
  4. 4
    If you upload with upsert: true, add SELECT and UPDATE policies with the same bucket and folder check.
  5. 5
    For a private bucket, add a SELECT policy so users can download their own files, or create signed URLs on the server.
  6. 6
    Sign in as two users and check each can upload and read only their own folder.

Which Storage error, which cause

We ran Supabase Postgres 17.11 and the Storage API v1.79.28 locally on 2026-10-25, uploaded to a private bucket, and checked the messages against Supabase's docs and the Storage server source that day. One message covers every row level security denial, so the operation that failed tells you which policy is missing.

What failed, why, and what fixes it

Supabase Storage errors on upload and download, with the cause and the fix
What you seeWhenCauseFix
new row violates row-level security policyUploadNo INSERT policy on storage.objects matches this user, bucket and pathAn INSERT policy with a bucket and folder check
new row violates row-level security policyUpload with upsert, or an updateNo SELECT or UPDATE policy, even for a new pathSELECT and UPDATE policies with the same check
Object not foundDownload from a private bucketNo SELECT policy, so the file looks missing rather than deniedA SELECT policy, or signed URLs made on the server
ERROR: must be owner of table objectsA migration runsalter table on storage.objects, which the postgres role does not ownDelete the alter line; keep the create policy statements

What our local run returned

The upload with no policies returned this body. It says 403 and AccessDenied, but the HTTP status was 400: the Storage server sends 400 for every client error and keeps the original status in the body.

JSON
{"statusCode":"403","error":"Unauthorized","message":"new row violates row-level security policy","code":"AccessDenied"}
Observed with Storage API v1.79.28 and Postgres 17.11, run locally; no hosted project
StepResult
alter table storage.objects enable row level security, as postgresERROR: must be owner of table objects. Every storage table already had row level security on
Upload to a private bucket with no policiesHTTP 400, with the body shown above the table
Same upload after the per-user INSERT policySucceeded
Upload to another user's folderDenied
Upsert to a new path with only the INSERT policyFailed: the insert asks Postgres to return the row, and no SELECT policy allowed it

Official docs behind this checklist

FAQ for builders before launch

Do I need to enable RLS on storage.objects?

No. It is already on, and you cannot change that table. Your migration only needs the create policy statements.

Why does the upload work with the service role key but not from the browser?

Supabase's docs say service keys bypass RLS policies entirely. The browser uploads as the signed-in user, and the policies apply to that user.