SupabaseStorageError Fix2026 Updated

Supabase Storage Upload Error— Permission Denied & More [Fixed 2026]

Also covers: bucket creation · storage RLS policies · file size limits · public URL · Server Action uploads

January 20266 min readSupabase Storage · Next.js · React

⚡ Common Errors

Error
{ statusCode: "403", error: "Unauthorized", message: "new row violates row-level security policy" }
// OR:
{ statusCode: "404", error: "Bucket not found" }
// OR:
{ statusCode: "413", error: "Payload Too Large" }

✅ Basic working upload pattern

Upload a file to Supabase Storage
const { data, error } = await supabase.storage
  .from("avatars")                // bucket name
  .upload(`${userId}/avatar.png`, file, {
    upsert: true,                 // overwrite if exists
    contentType: "image/png",
  })

if (error) console.error(error.message)

// Get public URL (public bucket only)
const { data: { publicUrl } } = supabase.storage
  .from("avatars")
  .getPublicUrl(`${userId}/avatar.png`)

Why Supabase Storage Uploads Fail

Storage errors have three main categories: permissions (RLS blocking the upload), configuration (bucket doesn't exist, wrong name, file too large), or code mistakes (wrong path in getPublicUrl, missing upsert flag on re-upload). Most errors are permissions-related.

1

Create the Bucket and Set Access Policy

Bucket not found OR all uploads fail
3 min
Supabase Dashboard → Storage → New Bucket
# Dashboard: Storage → New bucket
Bucket name:  avatars           (no spaces, lowercase)
Public bucket: ✅               (toggle ON for images shown to users)
File size limit: 5 MB           (adjust as needed)
Allowed MIME types: image/*     (optional — leave blank for all types)

# OR via SQL:
INSERT INTO storage.buckets (id, name, public, file_size_limit, allowed_mime_types)
VALUES (
  'avatars',
  'avatars',
  true,
  5242880,          -- 5MB in bytes
  ARRAY['image/jpeg', 'image/png', 'image/webp', 'image/gif']
);
2

Add Storage RLS Policies for Upload

403 Unauthorized on upload — most common fix
5 min

Storage uses RLS on the storage.objects table. For private buckets, you must add policies for INSERT (upload), SELECT (read), and DELETE.

Storage RLS policies — user-scoped uploads
-- Allow authenticated users to upload to their own folder
CREATE POLICY "Users upload own files"
  ON storage.objects FOR INSERT
  TO authenticated
  WITH CHECK (
    bucket_id = 'avatars'
    AND auth.uid()::text = (storage.foldername(name))[1]
  );
-- File path must be: {user-uuid}/filename.ext

-- Allow authenticated users to read their own files
CREATE POLICY "Users read own files"
  ON storage.objects FOR SELECT
  TO authenticated
  USING (
    bucket_id = 'avatars'
    AND auth.uid()::text = (storage.foldername(name))[1]
  );

-- Allow users to delete their own files
CREATE POLICY "Users delete own files"
  ON storage.objects FOR DELETE
  TO authenticated
  USING (
    bucket_id = 'avatars'
    AND auth.uid()::text = (storage.foldername(name))[1]
  );

-- For PUBLIC bucket — allow anyone to read (no auth needed)
CREATE POLICY "Public read avatars"
  ON storage.objects FOR SELECT
  TO anon, authenticated
  USING (bucket_id = 'avatars');
3

Fix File Size and MIME Type Limits

413 Payload Too Large or unsupported file type
2 min
Update bucket limits
-- Increase file size limit (in bytes)
UPDATE storage.buckets
SET file_size_limit = 52428800   -- 50MB
WHERE id = 'documents';

-- Update allowed MIME types
UPDATE storage.buckets
SET allowed_mime_types = ARRAY[
  'image/jpeg', 'image/png', 'image/webp',
  'application/pdf',
  'video/mp4'
]
WHERE id = 'uploads';

-- Validate file size client-side before uploading
const MAX_SIZE = 5 * 1024 * 1024  // 5MB
if (file.size > MAX_SIZE) {
  alert("File must be under 5MB")
  return
}
4

Get the Correct Public URL After Upload

Object not found or URL returns 404
2 min

The path in getPublicUrl must exactly match the path used during upload, including any folder prefix. For private buckets, use createSignedUrl instead.

Upload + get URL — complete pattern
async function uploadAvatar(userId: string, file: File) {
  const filePath = `${userId}/${Date.now()}-${file.name}`

  // Upload the file
  const { error: uploadError } = await supabase.storage
    .from("avatars")
    .upload(filePath, file, { upsert: true })

  if (uploadError) throw uploadError

  // Get public URL (public bucket)
  const { data: { publicUrl } } = supabase.storage
    .from("avatars")
    .getPublicUrl(filePath)      // ← same path as upload

  return publicUrl

  // For PRIVATE bucket — use signed URL instead:
  // const { data, error } = await supabase.storage
  //   .from("documents")
  //   .createSignedUrl(filePath, 60 * 60)  // expires in 1 hour
  // return data?.signedUrl
}
5

Upload Files from Next.js Server Actions

File uploads handled on the server
5 min

Read the file from FormData in a Server Action, then upload using the Supabase server client. Use the admin client to bypass storage RLS for server-side uploads.

app/actions/upload.ts
"use server"

import { createClient } from "@/lib/supabase/server"

export async function uploadAvatar(formData: FormData) {
  const file = formData.get("avatar") as File
  if (!file || file.size === 0) return { error: "No file provided" }

  const supabase = await createClient()
  const { data: { user } } = await supabase.auth.getUser()
  if (!user) return { error: "Not authenticated" }

  // Read file as ArrayBuffer
  const arrayBuffer = await file.arrayBuffer()
  const filePath = `${user.id}/${Date.now()}-${file.name}`

  const { error } = await supabase.storage
    .from("avatars")
    .upload(filePath, arrayBuffer, {
      contentType: file.type,
      upsert: true,
    })

  if (error) return { error: error.message }

  const { data: { publicUrl } } = supabase.storage
    .from("avatars")
    .getPublicUrl(filePath)

  // Save URL to user profile
  await supabase
    .from("profiles")
    .update({ avatar_url: publicUrl })
    .eq("id", user.id)

  return { publicUrl }
}

Prevention

Frequently Asked Questions

Why does Supabase Storage return 'permission denied'?+
Supabase Storage uses Row Level Security on the storage.objects table. By default, all uploads are denied. You must either make the bucket public (for public assets) or add storage RLS policies that allow authenticated users to upload to specific paths.
What is the difference between a public and private Supabase bucket?+
Public buckets allow anyone to read files via their public URL without authentication. Private buckets require a signed URL (created with createSignedUrl) or an authenticated request to access files. Use public buckets for images, avatars, and assets shown to all users. Use private buckets for sensitive documents.
What is the Supabase Storage file size limit?+
The default file size limit is 50MB. You can change this per bucket in the Supabase Dashboard when creating or editing a bucket. The free plan has a total storage limit of 1GB across all buckets.
How do I get the public URL of an uploaded file in Supabase?+
After uploading to a public bucket, call supabase.storage.from('bucket-name').getPublicUrl(filePath). This returns a permanent public URL. For private buckets, use createSignedUrl(filePath, expiresIn) to generate a time-limited URL.
Can I upload files from a Next.js Server Action?+
Yes. Create a Supabase server client in the Server Action, read the file from FormData as a File or ArrayBuffer, then call supabase.storage.from('bucket').upload(path, fileData). Use the service role client if you want to bypass storage RLS.
Why does my uploaded file show 'Object not found' when I try to access it?+
The file path in getPublicUrl must exactly match the path used in upload, including any folder prefix. Also check that the bucket is public — private bucket files require a signed URL to access, not the public URL endpoint.

Need Expert Help?

We Build File Upload Pipelines with Supabase

Softplix engineers implement Supabase Storage for avatars, documents, and media — with RLS, signed URLs, and image optimisation. Let us help.

Talk to an Engineer