This error occurs when Firebase Storage cannot identify or access the Firebase project, typically because the project was not properly initialized, the project ID is missing or incorrect in the configuration, or Cloud Storage has not been set up for the project.
The "storage/project-not-found" error indicates that Firebase Storage cannot locate or authenticate the Firebase project you are attempting to use. This differs from bucket-related errors—while those involve missing or misconfigured storage buckets, this error means Firebase cannot even identify which project should own the storage resources. Firebase Storage requires a properly configured Firebase project with valid credentials and project metadata. When Firebase's authentication system cannot resolve the project ID from your configuration or service account credentials, it throws this error to prevent operations on undefined or unauthorized projects. This error commonly appears when initializing Firebase incorrectly, using credentials from one project while attempting to access resources from another, or when the Firebase project itself has configuration issues such as a missing GCP resource location or incomplete Cloud Storage setup.
Ensure your Firebase app is properly initialized before accessing Storage. The initialization must happen before any Storage operations:
// Web SDK (modular v9+)
import { initializeApp } from "firebase/app";
import { getStorage } from "firebase/storage";
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "your-project.firebaseapp.com",
projectId: "your-project-id", // Must be present and correct
storageBucket: "your-project.firebasestorage.app",
messagingSenderId: "123456789",
appId: "YOUR_APP_ID"
};
// Initialize Firebase first
const app = initializeApp(firebaseConfig);
// Then get Storage reference
const storage = getStorage(app);// Admin SDK (Node.js)
import * as admin from 'firebase-admin';
// Initialize with explicit project ID
admin.initializeApp({
credential: admin.credential.applicationDefault(),
projectId: 'your-project-id', // Explicitly specify project
storageBucket: 'your-project.firebasestorage.app'
});Verify the projectId field matches your Firebase project exactly as shown in the Firebase Console.
Confirm you are using the correct project ID from the Firebase Console:
1. Open [Firebase Console](https://console.firebase.google.com/)
2. Select your project
3. Click the gear icon (⚙️) → Project settings
4. Find Project ID under "General" tab
5. Copy the exact project ID
Update your configuration with the correct project ID:
// Before
const firebaseConfig = {
projectId: "my-app", // ✗ Wrong
// ...
};
// After
const firebaseConfig = {
projectId: "my-app-prod-abc123", // ✓ Exact project ID
// ...
};For environment-based configurations:
# .env.local
NEXT_PUBLIC_FIREBASE_PROJECT_ID=my-app-prod-abc123const firebaseConfig = {
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
// ...
};If Cloud Storage has never been set up for your project, you must enable it first:
1. Go to [Firebase Console](https://console.firebase.google.com/) and select your project
2. Click Storage in the left navigation menu
3. If you see a "Get Started" button, Cloud Storage is not enabled yet
4. Click Get Started
5. Choose your security rules mode:
- Test mode: Allows all access (development only)
- Production mode: Requires authentication and rules
6. Select a storage location (cannot be changed later):
- us-central1 (Iowa)
- europe-west1 (Belgium)
- asia-northeast1 (Tokyo)
7. Click Done
Wait 10-30 seconds for Firebase to provision the default storage bucket. The bucket name will appear at the top of the Storage page once complete.
Some Firebase projects require an explicit GCP resource location before Cloud Storage can be used:
1. In Firebase Console, go to Project Settings → General
2. Scroll to "Default GCP resource location"
3. If it says "Not set" or is blank, click Set location
4. Choose a region that matches your user base:
- US: us-central1, us-east1, us-west1
- Europe: europe-west1, europe-west2
- Asia: asia-northeast1, asia-south1
5. Click Done
Warning: This location affects all GCP resources in your project (Firestore, Cloud Storage, Cloud Functions) and cannot be changed once set.
After setting the location, try accessing Storage again. The project-not-found error should be resolved.
If using Firebase Admin SDK, ensure your service account credentials match the Firebase project:
Check which project your service account belongs to:
import * as admin from 'firebase-admin';
import * as serviceAccount from './serviceAccountKey.json';
console.log('Service account project:', serviceAccount.project_id);The project_id in your service account JSON must match your Firebase project ID exactly.
Download correct service account key:
1. Go to Firebase Console → Project Settings → Service accounts
2. Click Generate new private key
3. Save the JSON file securely
4. Update your code to use the new key:
import * as admin from 'firebase-admin';
import * as serviceAccount from './path/to/new-serviceAccountKey.json';
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
storageBucket: 'your-project.firebasestorage.app'
});Using Application Default Credentials (ADC):
# Set the environment variable to your service account key
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/serviceAccountKey.json"import * as admin from 'firebase-admin';
admin.initializeApp({
credential: admin.credential.applicationDefault(),
projectId: 'your-project-id', // Explicitly specify
storageBucket: 'your-project.firebasestorage.app'
});Create a diagnostic script to verify your project configuration:
import { initializeApp } from "firebase/app";
import { getStorage, ref, listAll } from "firebase/storage";
const firebaseConfig = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID
};
async function diagnoseStorage() {
console.log('=== Firebase Storage Diagnostics ===');
console.log('Project ID:', firebaseConfig.projectId);
console.log('Storage Bucket:', firebaseConfig.storageBucket);
try {
const app = initializeApp(firebaseConfig);
console.log('✓ Firebase initialized successfully');
const storage = getStorage(app);
console.log('✓ Storage instance created');
const listRef = ref(storage, '/');
const result = await listAll(listRef);
console.log('✓ Storage accessible. Files:', result.items.length);
console.log('✓ All checks passed!');
} catch (error) {
if (error.code === 'storage/project-not-found') {
console.error('✗ Project not found. Check project ID and credentials.');
} else if (error.code === 'storage/bucket-not-found') {
console.error('✗ Bucket not found. Enable Storage in Firebase Console.');
} else {
console.error('✗ Error:', error.code, error.message);
}
}
}
diagnoseStorage();Run this script and review the output to identify configuration issues.
For multi-tenant applications or systems managing multiple Firebase projects, use separate Firebase app instances:
import { initializeApp, getApps } from "firebase/app";
import { getStorage } from "firebase/storage";
const projectConfigs = {
clientA: {
projectId: 'client-a-project',
storageBucket: 'client-a.firebasestorage.app',
// ... other config
},
clientB: {
projectId: 'client-b-project',
storageBucket: 'client-b.firebasestorage.app',
// ... other config
}
};
// Initialize separate apps with names
const appA = initializeApp(projectConfigs.clientA, 'clientA');
const appB = initializeApp(projectConfigs.clientB, 'clientB');
// Get storage for specific project
const storageA = getStorage(appA);
const storageB = getStorage(appB);Cloud Functions Environment: When using Firebase Cloud Functions, the project ID is automatically inferred from the function's deployment environment. However, if you need to access a different project's storage, you must explicitly initialize with that project's credentials:
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
// Default project (same as Cloud Function)
admin.initializeApp();
// Access external project storage
const externalApp = admin.initializeApp({
credential: admin.credential.cert(externalServiceAccount),
projectId: 'external-project-id',
storageBucket: 'external-project.firebasestorage.app'
}, 'external');
const externalStorage = externalApp.storage();Troubleshooting Firebase Admin SDK in Cloud Run/App Engine: If deploying to Google Cloud Run or App Engine and encountering project-not-found errors, ensure your service has the correct IAM bindings:
# Grant the default compute service account Storage Admin role
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:[email protected]" \
--role="roles/storage.admin"Alternatively, use a custom service account with explicit permissions rather than the default compute service account.
Emulator Suite: When using Firebase Local Emulator Suite, this error may occur if the emulator is not properly configured. Ensure you're connecting to the Storage emulator:
import { getStorage, connectStorageEmulator } from "firebase/storage";
const storage = getStorage();
if (process.env.NODE_ENV === 'development') {
connectStorageEmulator(storage, 'localhost', 9199);
}And verify firebase.json includes the Storage emulator configuration:
{
"emulators": {
"storage": {
"port": 9199
}
}
}Project Migration: If you recently migrated from one Firebase project to another, ensure all environment variables, service account keys, and configuration files reference the new project ID. A common mistake is updating the code repository but forgetting to update CI/CD environment variables or deployment secrets.
Callable Functions: INTERNAL - Unhandled exception
How to fix "Callable Functions: INTERNAL - Unhandled exception" in Firebase
auth/invalid-hash-algorithm: Hash algorithm doesn't match supported options
How to fix "auth/invalid-hash-algorithm: Hash algorithm doesn't match supported options" in Firebase
Hosting: CORS configuration not set up properly
How to fix CORS configuration in Firebase Hosting
auth/reserved-claims: Custom claims use reserved OIDC claim names
How to fix "reserved claims" error when setting custom claims in Firebase
Callable Functions: UNAUTHENTICATED - Invalid credentials
How to fix "UNAUTHENTICATED - Invalid credentials" in Firebase Callable Functions