Firestore/Firebase Emulator Not Running

I had the same issue there were a few things wrong for me

  1. 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"
    }
  }
}

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 or firebase serve --only functions,firestore.
  • Keep in mind that pubsub is not suported yet. As Sam Stern comments, pub sub is now supported.

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.