1

I was unable to run functions shell without the emulators. It always error'd with

Error: Port 9001 is not open on localhost, could not start functions emulator.

I'm running a Mac with

  "firebase": "^7.24.0",
  "firebase-admin": "^9.9.0",
  "firebase-functions": "^3.14.1",

and here's my firebase.json

{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ],
    "source": "functions"
  },
  "emulators": {
    "functions": {
      "host": "localhost",
      "port": "9001"
    },
    "firestore": {
      "port": "9002",
      "rules": "firestore.rules"
    },
    "pubsub": {
      "port": "9004"
    }
  },
  "hosting": {
    "public":"public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "appAssociation": "AUTO",
    "rewrites": [ {
      "source": "/**", 
      "dynamicLinks": true
    } ]
  }
}

When running emulators and functions together I get a warning saying you might get unusual behaviour so it doesn't look like its the correct solution.

I tried this but it didn't work in my case but worth noting: Firebase serve error: Port 5000 is not open. Could not start functions emulator

Cleanbeans
  • 655
  • 4
  • 12
  • Please post your solution as an answer, instead of in the question. That way you can accept it (which makes it more findable), and others can upvote it separately. – Frank van Puffelen Jun 07 '21 at 14:59

1 Answers1

1

Posting hoping to help someone out. In your firebase.json make sure your port number is a number not a string.

So

  "emulators": {
    "functions": {
      "host": "localhost",
      "port": 9001
    },

Not

  "emulators": {
    "functions": {
      "host": "localhost",
      "port": "9001"
    }
Cleanbeans
  • 655
  • 4
  • 12