Skip to content
>_VibeUnstuck

Bucket not found

Last verified:

The fix

Bucket not found. Supabase Storage has no bucket with that id in this project. Create it, or pass the id exactly. A policy denial is a different message.

  1. 1

    Compare the id in the code to the bucket list

    In Storage, read the bucket name character for character, including case. The string passed to .from() has to be that name. Do not use the file name, the folder, or a display label you never created.

    const { data, error } = await supabase.storage
      .from("avatars")
      .upload(path, file);
    
    if (error?.message === "Bucket not found") {
      // "avatars" is not a bucket id in this project
    }
  2. 2

    Create the bucket if the list does not have it

    Create it in the dashboard, or in a migration, with that exact id. Public means the browser can read objects by URL. It is a separate switch from whether the bucket exists. Do not flip it to public to get past a 404.

  3. 3

    Point the client at this project

    The Supabase URL host should be the project where the bucket is listed. Restart the dev server after changing a VITE_ or NEXT_PUBLIC_ value, and publish again so the hosted app picks it up. Do not ship the service role key in that variable.

  4. 4

    Stop when the message changes to row-level security

    A 404 is a missing id. A policy error means the bucket exists and storage.objects rejected the role. Add a storage policy for that operation. Do not create a second bucket. The insert policy page is the shape of that fix, on storage.objects rather than a public table.

Why it happens

Storage looks up the bucket id on the request. When no bucket has that id, the API returns 404 and the body is Bucket not found. The id is the name you gave the bucket when you created it. It is case-sensitive. Avatars and avatars are different buckets.

The client URL and anon key have to be the project where you created the bucket. A Lovable preview pointed at another project, or an empty VITE_SUPABASE_URL, uploads to the wrong place or never leaves the browser. An empty URL is the supabaseUrl is required page. A bucket that exists and then refuses the upload says new row violates row-level security policy on storage.objects, or returns unauthorized. Making the bucket public does not create a missing id. The service role key bypasses policies and still 404s when the id does not exist. Do not put that key in the browser to test the name.

The next error you'll probably hit

Once this is fixed, the usual follow-up is supabaseUrl is required. supabaseUrl is required: createClient got an empty URL or key, missing when the bundle was built. Set the Supabase URL and anon key, then rebuild.

Prompt to paste back into your AI tool

Paste this above the error.

Supabase Storage returns 404: Bucket not found. The code calls storage.from("<id>"). The buckets listed in this project are <names, or unknown>.

Do not put the service role key in the client. Do not make a bucket public to fix a 404. Do not disable RLS. If the message is new row violates row-level security policy, stop. That is a different error.

1. If no bucket uses this id, tell me to create it with this exact name, or change .from() to an id that exists. Respect case.
2. If the URL is a different project, say so. Do not invent a bucket in the wrong project.
3. Leave public/private as it is unless I asked. A 404 is not a visibility setting.
4. Change only the bucket id or the upload call.

Common questions

+The bucket is in the dashboard and the upload still says Bucket not found. Why?

The id does not match, including case, or the client is using another project's URL. Read the name in Storage and the string in .from(). They have to be the same project.

+Should I mark the bucket public?

Not for this error. Public changes who can read an object URL. Bucket not found means the id is not there. A policy error is the message you get after the bucket exists and the role is denied.

Related errors