How to fix database/not-found in Firebase
The "database/not-found" error occurs when your Firebase Realtime Database configuration is missing, incorrect, or points to a non-existent database. Fix it by ensuring your databaseURL is properly configured in your Firebase initialization code.
Quick fix
Fixes database/not-found
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "your-project.firebaseapp.com",
projectId: "your-project",
storageBucket: "your-project.appspot.com",
messagingSenderId: "YOUR_SENDER_ID",
appId: "YOUR_APP_ID",
databaseURL: "https://your-project.firebaseio.com" // Add this line
};
firebase.initializeApp(firebaseConfig);- Verify your database URL in Firebase console
- Add databaseURL to your Firebase configuration
- Use correct URL format for regional databases
- Initialize Firebase before accessing the database
const firebaseConfig = {apiKey: "YOUR_API_KEY",authDomain: "your-project.firebaseapp.com",projectId: "your-project",storageBucket: "your-project.appspot.com",messagingSenderId: "YOUR_SENDER_ID",appId: "YOUR_APP_ID",databaseURL: "https://your-project.firebaseio.com" // Add this line};firebase.initializeApp(firebaseConfig);database/not-found
What this error means
The "database/not-found" error is thrown when your application cannot locate or connect to the Firebase Realtime Database instance. This typically happens when the database URL is missing from your Firebase configuration, incorrectly formatted, or points to a database that does not exist in your Firebase project. Unlike Firestore (which is included by default), Realtime Database requires an explicit URL to be configured. Firebase cannot automatically determine which database instance you want to use, especially if your project has multiple databases or databases in different regions.
Typical symptoms
- Application crashes when trying to access Firebase Realtime Database
- Error messages contain "database/not-found" or "Can't determine Firebase Database URL"
- Database operations fail silently without specific error messages
- Firebase functions deployment fails with database URL errors
- Realtime Database listener does not initialize or fires cancellation callbacks
Common causes
- The databaseURL is missing from your Firebase configuration object during initialization
- The databaseURL is incorrectly formatted (wrong region format or typo in project name)
- The database exists in a non-us-central1 region but you're using the wrong URL format
- Firebase is not properly initialized before attempting to access the database
- You're referencing a database in a different Firebase project than your config points to
- The Realtime Database service is not enabled in your Firebase console for that project
How to fix "database/not-found"
Log into your Firebase Console, navigate to "Realtime Database", and find your database instance. Copy the full database URL (it will appear at the top of the database tab). It should look like:
- https://YOUR_PROJECT_ID.firebaseio.com (for us-central1)
- https://YOUR_PROJECT_ID.REGION.firebasedatabase.app (for other regions like europe-west1, asia-southeast1)
Update your Firebase initialization to include the databaseURL. In a web/JavaScript app:
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "your-project.firebaseapp.com",
projectId: "your-project",
storageBucket: "your-project.appspot.com",
messagingSenderId: "YOUR_SENDER_ID",
appId: "YOUR_APP_ID",
databaseURL: "https://your-project.firebaseio.com" // Add this line
};
firebase.initializeApp(firebaseConfig);If your database is in a region other than us-central1, ensure you use the correct URL format with the region included:
// For Europe region
databaseURL: "https://my-db.europe-west1.firebasedatabase.app"
// For Asia Southeast region
databaseURL: "https://my-db.asia-southeast1.firebasedatabase.app"Do not use the old .firebaseio.com format for regional databases.
Ensure Firebase is fully initialized before calling any database methods. In a Node.js/Admin SDK context:
const admin = require("firebase-admin");
const serviceAccount = require("./serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://your-project.firebaseio.com"
});
const database = admin.database();
// Now database calls will workVisit your Firebase Console project settings and confirm that the Firebase Realtime Database is enabled. If you only see Firestore options or if the database is not created, click "Create database" in the Realtime Database section. Choose your preferred security rules and location.
Advanced notes
Regional databases require special attention when migrating or using multiple database instances. If your project has multiple Realtime Database instances, each one will have a unique URL. You can create multiple database references by passing different URLs to getInstance() methods in your SDK. In React Native and Flutter, the database URL parameter is required even for the default us-central1 database. When deploying Firebase Functions, ensure your firebase.json includes the correct databaseURL in the functions configuration section.
Frequently asked questions
- What does "database/not-found" mean?
- The "database/not-found" error is thrown when your application cannot locate or connect to the Firebase Realtime Database instance. This typically happens when the database URL is missing from your Firebase configuration, incorrectly formatted, or points to a database that does not exist in your Firebase project. Unlike Firestore (which is included by default), Realtime Database requires an explicit URL to be configured.
- How do I fix "database/not-found"?
- The "database/not-found" error occurs when your Firebase Realtime Database configuration is missing, incorrect, or points to a non-existent database. Fix it by ensuring your databaseURL is properly configured in your Firebase initialization code.
- What causes "database/not-found"?
- The databaseURL is missing from your Firebase configuration object during initialization The databaseURL is incorrectly formatted (wrong region format or typo in project name) The database exists in a non-us-central1 region but you're using the wrong URL format
- Is the "database/not-found" 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 - start(Official Docs)
- ๐firebase.google.com - DatabaseReference(Official Docs)
- ๐
- ๐github.com - 4211(GitHub)
- ๐