How to fix storage/object-not-found: No object exists at specified reference in Firebase
This error occurs when attempting to access, download, or retrieve metadata for a file that does not exist in Firebase Storage at the given path. The fix involves verifying the file path, ensuring the file was successfully uploaded, and checking Storage security rules.
Quick fix
Fixes storage/object-not-found: No object exists at specified reference
// Correct - no leading slash
const correctRef = ref(storage, "users/123/profile.jpg");
// Incorrect - leading slash creates different path
const incorrectRef = ref(storage, "/users/123/profile.jpg");- Verify the file exists in Firebase Console
- Double-check your storage reference path
- List files to verify actual paths
- Ensure upload completes before accessing file
// Correct - no leading slashconst correctRef = ref(storage, "users/123/profile.jpg");// Incorrect - leading slash creates different pathconst incorrectRef = ref(storage, "/users/123/profile.jpg");storage/object-not-found: No object exists at specified reference
What this error means
The "storage/object-not-found" error indicates that Firebase Storage cannot locate a file at the path you're trying to access. This is one of the most common Firebase Storage errors and occurs when the SDK attempts operations like getDownloadURL(), getMetadata(), or delete() on a reference that points to a non-existent object. Firebase Storage uses a hierarchical path structure similar to a file system. When you create a reference like ref(storage, "images/profile.jpg"), Firebase expects a file to exist at that exact path in your Storage bucket. If the file was never uploaded, was deleted, or the path contains typos or case mismatches, the operation will fail with this error. Unlike file systems, Firebase Storage paths are case-sensitive and exact. A file at "users/123/photo.jpg" is completely different from "Users/123/photo.jpg" or "users/123/Photo.jpg". Additionally, this error can occur during race conditions where code tries to access a file before an upload completes, or when relying on stale references after deletions.
Typical symptoms
- getDownloadURL() throws "storage/object-not-found" error
- getMetadata() fails with "No object exists at specified reference"
- File download or deletion operations fail
- Error occurs after deleting a file and trying to access it again
- Works in Firebase Console but fails in your application
- Inconsistent behavior between development and production environments
Common causes
- File was never uploaded to the specified path
- Incorrect file path or filename (typos, case sensitivity issues)
- File was deleted but code still references the old path
- Attempting to access file before upload completes (race condition)
- Using wrong storage bucket (multi-bucket projects)
- Path contains invalid characters or special formatting
- Security rules blocking access (appears as object-not-found instead of unauthorized)
- Recent Firebase bucket URL migration (appspot.com vs firebasestorage.app)
How to fix "storage/object-not-found: No object exists at specified reference"
Open the [Firebase Console](https://console.firebase.google.com/), navigate to Storage, and manually browse to the path where you expect the file to be located.
Check:
- Does the file exist at the exact path you're using?
- Is the filename spelled correctly (case-sensitive)?
- Are there any unexpected folder structures?
If the file doesn't exist, you'll need to upload it first or fix your upload logic before trying to access it.
Ensure your code uses the correct path syntax. Firebase Storage paths should NOT start with a forward slash:
// Correct - no leading slash
const correctRef = ref(storage, "users/123/profile.jpg");
// Incorrect - leading slash creates different path
const incorrectRef = ref(storage, "/users/123/profile.jpg");Verify the path matches exactly:
import { getStorage, ref, getDownloadURL } from "firebase/storage";
const storage = getStorage();
const fileRef = ref(storage, "images/photo.jpg");
console.log("Full path:", fileRef.fullPath);
console.log("Bucket:", fileRef.bucket);
try {
const url = await getDownloadURL(fileRef);
console.log("Success:", url);
} catch (error) {
console.error("Error accessing file:", error.code, error.message);
console.error("Attempted path:", fileRef.fullPath);
}Compare the logged path with what you see in the Firebase Console.
Use the listAll() method to see what files actually exist in a directory:
import { getStorage, ref, listAll } from "firebase/storage";
const storage = getStorage();
const listRef = ref(storage, "users/123");
try {
const result = await listAll(listRef);
console.log("Files in directory:");
result.items.forEach((itemRef) => {
console.log(" -", itemRef.fullPath);
});
console.log("\nSubdirectories:");
result.prefixes.forEach((folderRef) => {
console.log(" -", folderRef.fullPath);
});
} catch (error) {
console.error("Error listing files:", error);
}This helps identify typos, unexpected folder structures, or files in different locations than expected.
If you're trying to access a file immediately after uploading, ensure the upload promise resolves first:
import { getStorage, ref, uploadBytes, getDownloadURL } from "firebase/storage";
const storage = getStorage();
const fileRef = ref(storage, "uploads/document.pdf");
async function uploadAndGetURL(file) {
try {
// Wait for upload to complete
const snapshot = await uploadBytes(fileRef, file);
console.log("Upload successful:", snapshot.metadata.fullPath);
// Now safe to get download URL
const downloadURL = await getDownloadURL(fileRef);
console.log("Download URL:", downloadURL);
return downloadURL;
} catch (error) {
console.error("Upload or URL retrieval failed:", error);
throw error;
}
}For upload tasks with progress monitoring:
import { uploadBytesResumable, getDownloadURL } from "firebase/storage";
const uploadTask = uploadBytesResumable(fileRef, file);
uploadTask.on("state_changed",
(snapshot) => {
const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
console.log("Upload is " + progress + "% done");
},
(error) => {
console.error("Upload failed:", error);
},
async () => {
// Upload completed successfully
const downloadURL = await getDownloadURL(uploadTask.snapshot.ref);
console.log("File available at:", downloadURL);
}
);Sometimes restrictive security rules return "object-not-found" instead of "unauthorized". Review your Firebase Storage rules:
In the Firebase Console, go to Storage → Rules and verify read access is allowed:
// Example: Allow authenticated users to read their own files
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /users/{userId}/{allPaths=**} {
allow read: if request.auth != null && request.auth.uid == userId;
allow write: if request.auth != null && request.auth.uid == userId;
}
}
}For testing purposes only (NOT for production):
// Allow public read access - USE ONLY FOR TESTING
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read: if true;
allow write: if request.auth != null;
}
}
}Deploy the rules and test again. If the error disappears, the issue was permissions, not a missing file.
If your project uses multiple storage buckets, ensure you're referencing the correct one:
import { getStorage, ref } from "firebase/storage";
// Default bucket
const defaultStorage = getStorage();
// Specific bucket
const customStorage = getStorage(app, "gs://my-other-bucket.appspot.com");
// Create reference in the correct bucket
const fileRef = ref(customStorage, "path/to/file.jpg");Check the Firebase Console to see which bucket contains your file, especially if you recently migrated or have legacy and new buckets (.appspot.com vs .firebasestorage.app).
Advanced notes
For production applications, implement robust error handling that distinguishes between object-not-found and other storage errors:
import { getDownloadURL, ref } from "firebase/storage";
async function safeGetDownloadURL(path) {
const storage = getStorage();
const fileRef = ref(storage, path);
try {
return await getDownloadURL(fileRef);
} catch (error) {
if (error.code === "storage/object-not-found") {
console.warn(`File not found: ${path}`);
// Return placeholder or trigger upload
return "/default-image.png";
} else if (error.code === "storage/unauthorized") {
console.error("Permission denied:", path);
throw new Error("You don't have access to this file");
} else {
console.error("Unexpected storage error:", error);
throw error;
}
}
}Database consistency: If you store file paths in Firestore or Realtime Database, ensure you update or delete those references when files are deleted:
import { deleteObject, ref } from "firebase/storage";
import { doc, deleteField, updateDoc } from "firebase/firestore";
async function deleteFileAndReference(userId, fileName) {
const storage = getStorage();
const db = getFirestore();
const fileRef = ref(storage, `users/${userId}/${fileName}`);
const userDoc = doc(db, "users", userId);
try {
// Delete file from storage
await deleteObject(fileRef);
// Remove reference from Firestore
await updateDoc(userDoc, {
profileImage: deleteField()
});
console.log("File and reference deleted successfully");
} catch (error) {
console.error("Deletion failed:", error);
throw error;
}
}October 2024 bucket migration: Firebase introduced new bucket URLs (.firebasestorage.app). If you're using refFromURL() with hardcoded bucket URLs, verify you're using the correct format shown in your Firebase Console. The old .appspot.com format still works for existing projects, but new projects use the new domain.
Flutter/React Native considerations: In mobile frameworks, ensure you're using the correct bucket reference method. Some SDKs had bugs where refFromURL() was required instead of the simpler ref() constructor when working with non-default buckets.
Frequently asked questions
- What does "storage/object-not-found: No object exists at specified reference" mean?
- The "storage/object-not-found" error indicates that Firebase Storage cannot locate a file at the path you're trying to access. This is one of the most common Firebase Storage errors and occurs when the SDK attempts operations like getDownloadURL(), getMetadata(), or delete() on a reference that points to a non-existent object. Firebase Storage uses a hierarchical path structure similar to a file system.
- How do I fix "storage/object-not-found: No object exists at specified reference"?
- This error occurs when attempting to access, download, or retrieve metadata for a file that does not exist in Firebase Storage at the given path. The fix involves verifying the file path, ensuring the file was successfully uploaded, and checking Storage security rules.
- What causes "storage/object-not-found: No object exists at specified reference"?
- File was never uploaded to the specified path Incorrect file path or filename (typos, case sensitivity issues) File was deleted but code still references the old path
- Is the "storage/object-not-found: No object exists at specified reference" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚Firebase Official Documentation
- 📖firebase.google.com - download files(Official Docs)
- 📖firebase.google.com - create reference(Official Docs)
- 📖firebase.google.com - handle errors(Official Docs)
- 🐙github.com - 10984(GitHub)
- 🐙github.com - 4908(GitHub)
- 🐙github.com - 6160(GitHub)
- 🔗
- 🐙github.com - 3156(GitHub)
- 🐙github.com - 1736(GitHub)