Search code examples
firebasefirebase-tools

How to change the Firebase Emulator Hub port?


When running the Firebase emulator, I get the following port information.

┌────────────────┬────────────────┬─────────────────────────────────┐
│ Emulator       │ Host:Port      │ View in Emulator UI             │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Authentication │ 127.0.0.1:9099 │ http://127.0.0.1:4000/auth      │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Functions      │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Firestore      │ 127.0.0.1:8080 │ http://127.0.0.1:4000/firestore │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Storage        │ 127.0.0.1:9199 │ http://127.0.0.1:4000/storage   │
└────────────────┴────────────────┴─────────────────────────────────┘
  Emulator Hub running at 127.0.0.1:4400
  Other reserved ports: 4500, 9150

I can set all ports in the firebase.json like so:

  "emulators": {
    "auth": {
      "port": 9099
    },
    "functions": {
      "port": 5001
    },
    ...
  }

But that doesn't work for the Emulator Hub running at 127.0.0.1:4400. (I want storybook to use port 4400)

  "emulators": {
    "hub": {
      "port": 4401
    },

This seemed to be implied by the Hub Rest API response. However, when I start the emulator, it simply deletes my hub configuration.

Is there a way to change the Emulator Hub port?


Solution

  • You can set the port in firebase.json like so:

    "emulators": {
        ...
        "hub": {
          "port": 9222
        }
      },
    
    $ firebase emulators:start
    ...
    Emulator Hub running at 127.0.0.1:9222
    

    However, when I start the emulator, it simply deletes my hub configuration.

    This sounds like a bug. If you can provide a minimum reproducible example the team can take a look:

    https://github.com/firebase/firebase-tools/issues/new/choose