Search code examples
node.jsfirebasegoogle-cloud-functionsfirebase-tools

Firebase Emulator - UI says emulators disconnected, command times out after 60 seconds


When I run firebase emulators:start in my project, the command has the following output:

i  emulators: Starting emulators: functions, firestore, hosting
⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, pubsub, storage
⚠  Your requested "node" version "16" doesn't match your global version "18". Using node@18 from host.
⚠  firestore: Did not find a Cloud Firestore rules file specified in a firebase.json config file.
⚠  firestore: The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration.
i  firestore: Firestore Emulator logging to firestore-debug.log
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://127.0.0.1:9001
i  ui: Emulator UI logging to ui-debug.log

When I open the emulator UI at localhost:4000, I get the a message saying the emulators are disconected: Emulator UI. Despite this message, the emulators are still running and I can access the hosting at localhost:9001.

Eventually, the emulator command stops with this error message:

Error: TIMEOUT: Port 4000 on localhost was not active within 60000ms

despite the fact that I did open the emulator UI at port 4000.

This is at the top of ui-debug.log:

Web / API server started at localhost:4000
u [FetchError]: request to http://localhost:4400/emulators failed, reason: connect ECONNREFUSED ::1:4400
    at ClientRequest.<anonymous> (/Users/patrick/.cache/firebase/emulators/ui-v1.7.0/server.bundle.js:326:16909)
    at ClientRequest.emit (node:events:527:28)
    at Socket.socketErrorListener (node:_http_client:454:9)
    at Socket.emit (node:events:527:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  type: 'system',
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED'
}

Sometimes, but not all the time, before stopping it will give this message:

i  ui: Stopping Emulator UI
⚠  Emulator UI has exited upon receiving signal: SIGINT

but with no clear explanation.


Solution

  • They've raised this issue on firebase-tools. Specifying host as "127.0.0.1" instead of the default "localhost" also worked for me.

    {
      "emulators": {
        "auth": {
          "port": 9099
        },
        "firestore": {
          "port": 8080
        },
        "hub": {
          "host": "127.0.0.1"
        },
        "ui": {
          "enabled": true,
          "host": "127.0.0.1"
        }
      }
    }