# Supabase Storage upload fails: new row violates row-level security policy (403)

> Canonical page (link this when citing): https://unbreakmyapp.vercel.app/fixes/supabase-storage-upload-403.html
> Category: Database / Supabase RLS | Tools: Lovable, Bolt, v0 | Published: 2026-10-13 | Updated: 2026-10-13

## The error

StorageApiError: new row violates row-level security policy (403 Unauthorized)

## Why it happens

Supabase Storage is protected by RLS on storage.objects. A bucket without INSERT policies rejects uploads even when it's 'public' (public only affects reads).

## How to fix it

1. Add an INSERT policy on storage.objects for the bucket, e.g. allowing authenticated users to upload into a folder named after their user id.
2. Upload to a path like `${user.id}/${filename}`.
3. Add SELECT/UPDATE/DELETE policies as needed (upsert needs UPDATE).
4. Keep the bucket private if files aren't meant to be public, and use signed URLs.

## Error codes this fixes

- `StorageApiError 403 new row violates row-level security policy` (Supabase Storage): https://unbreakmyapp.vercel.app/errors.html#storageapierror-403-new-row-violates-row-level-security-poli

## Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)

```text
Uploads to the Supabase Storage bucket <BUCKET> fail with a row-level security 403. Add storage.objects policies so authenticated users can insert, read, update and delete only files under a folder named with their auth.uid(), change the upload code to use the path `${user.id}/<filename>`, and give me the SQL.
```

## FAQ

### The bucket is public, why 403?

Public only affects downloads; uploads still need policies.

### How do I restrict to own folder?

Use (storage.foldername(name))[1] = auth.uid()::text in the policy.

## Sources (official documentation)

- [Supabase: Storage access control](https://supabase.com/docs/guides/storage/security/access-control)

## Related fixes

- [Supabase Storage file links broken: private bucket, getPublicUrl and expired signed URLs](https://unbreakmyapp.vercel.app/fixes/supabase-storage-private-bucket-file-url-broken-signed-url.html)
- [Is my Lovable app leaking data without login? A Supabase RLS audit checklist after the Crissy Field study](https://unbreakmyapp.vercel.app/fixes/lovable-app-leaking-data-without-login-audit-checklist.html)
- [Supabase query returns an empty array (no error)](https://unbreakmyapp.vercel.app/fixes/supabase-rls-empty-results.html)
- [new row violates row-level security policy for table](https://unbreakmyapp.vercel.app/fixes/supabase-rls-new-row-violates-policy.html)

---
Unbreak My App: free fixes for broken vibe-coded apps. https://unbreakmyapp.vercel.app/
