Firestore/Firebase Emulator Not Running
Solution 1
I had the same issue there were a few things wrong for me
- ensure the emulator is installed by running
firebase setup:emulators:firestore
My second issue was that my initial firebase configuration had installed the config files into my home folder rather then the project folder as described [here] this meant so my project was missing firestore.rules and firestore.indexes.json and some of the configuration settings.
run firebase init
to generate these files
Once I fixed these two things it worked for me. I hope this helps.
As a reference my firebase.json looks like this
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
},
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"hosting": {
"public": "dist",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"emulators": {
"firestore": {
"port": "5002"
}
}
}
Solution 2
If checking Firebase setup doesn't work, try this:
- Run
firebase emulators:start
. Check if displayed error request to install OpenJDK. - If your functions interacts with Firebase APIs or Google APIs, you need to setup admin credentials. Check how to do it here: https://firebase.google.com/docs/functions/local-emulator
- You may need to emulate functions and firestore at the same time. Use
firebase emulators:start --only functions,firestore
orfirebase serve --only functions,firestore
. -
Keep in mind that pubsub is not suported yet.As Sam Stern comments, pub sub is now supported.
Solution 3
Could be you don't have firestore configured properly in your firebase.json file. This makes emulator not being started.
What you need is to run firebase init firestore
in your project directory. This would create firestore rules and indexes files and update your firebase.json correspondingly.
Solution 4
As of version 7.8.0
of the Firebase CLI (firebase-tools
) there is a new command firebase init emulators
that will help you set up all the emulators you want to run.
Solution 5
Actually this error comes when the user initialize the firebase project without database.
So the command firebase emulators:start --only database
can not start the database emulator because it need the "database.rules.json" file and the configuration entries for database in the firebase.json file .
So if you forgot to initialize the database in firebase init
command then you can add firebase database whenever you want by following firebase CLI command
firebase init database
then you can run
firebase emulators:start --only database
for starting the database emulator in the localserver .
and If you want to use emulator for both function and database then run
firebase serve --only functions,database
![siefix](https://i.stack.imgur.com/QojTW.jpg?s=256&g=1)
siefix
Updated on July 09, 2022Comments
-
siefix almost 2 years
I'm trying to test my functions locally using the guide listed here https://firebase.google.com/docs/functions/local-emulator
I have installed the latest firebase-tools using
npm install -g firebase-tools
In my
package.json
I confirmed to be running"firebase-admin": "^7.3.0", "firebase-functions": "^2.3.1",
When I try to run my functions using
firebase emulators:start
It gives me the below output. What am I doing wrong?
Starting emulators: ["functions"] ⚠ Your requested "node" version "8" doesn't match your global version "11" ✔ functions: Emulator started at http://localhost:5001 i functions: Watching "[FUNCTIONS FOLDER PATH]" for Cloud Functions... ⚠ Default "firebase-admin" instance created! ⚠ Ignoring trigger "[FUNCTION NAME]" because the service "firebaseauth.googleapis.com" is not yet supported. ⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. ⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. ⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. ⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. ⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. ⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. ⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. ⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. ⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. ⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. ⚠ Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. etc. etc. etc. i functions: HTTP trigger initialized at http://localhost:5001/[APP NAME]/us-central1/[FUNCTION NAME] [2019-05-15T21:43:52.436Z] @firebase/database: FIREBASE WARNING: {"code":"app/invalid-credential","message":"Credential implementation provided to initializeApp() via the \"credential\" property failed to fetch a valid Google OAuth2 access token with the following error: \"Error fetching access token: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal metadata.google.internal:80. Error code: ENOTFOUND\"."}
-
Aswin Kumar about 5 yearsRunning
firebase init
did fix the issue. On the other hand, I had just created a new folder for functions and ran init. Weird that I had to run it again, didn't firebase know that I was using firestore and functions together initially itself? :-/ -
Maslow about 5 yearsAgree with @AswinKumar
-
Rami Alloush over 4 yearsI used
firebase init database
for Realtime Database -
Sam Stern over 4 yearsActually
pubsub
is supported as of the latest release (7.9.0
) -
Ayyappa over 4 yearsThis is the key! Thanks Sam for pointing out. Looks like I didn't find any where about this. If not added, would be great if you can add to the documentation.
-
Abdullah Khan about 4 years
firebase init
not work for me.firebase init firestore
solve my problem. -
Paulo Busato Favarato over 3 yearsI'm getting rror: functions firestore is not a valid emulator name, valid options are: ["auth","functions","firestore","database","hosting","pubsub"] when using firebase emulators:start --only functions,firestore
-
Frank Harrison about 2 years