firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.02k stars 937 forks source link

Error: TIMEOUT: Port 8080 on localhost was not active within 30000ms #2379

Closed dave-k closed 2 years ago

dave-k commented 4 years ago

firebase-debug.log Cloud Firestore emulator quickstart I am getting the Timeout error running the emulators:exec command on an unchanged project.

I tried other ports 8081, 8082 and

$ sudo firebase emulators:exec --only firestore 'npm test'
$ firebase emulators:exec 'npm test'
$ firebase emulators:start

produced the same Timeout error.


./firebase/quickstart-nodejs/firestore-emulator/javascript-quickstart

macOS v 10.15.6

$ firebase --version
8.4.2
$ node --version
v14.4.0
$ 
$ firebase emulators:exec --only firestore 'npm test'
i  emulators: Starting emulators: firestore
i  firestore: Firestore Emulator logging to firestore-debug.log
i  emulators: Shutting down emulators.

Error: TIMEOUT: Port 8080 on localhost was not active within 30000ms
ruohola commented 2 years ago

I got the emulators running again by specifying host as "127.0.0.1" instead of the default "localhost". I have no idea what changed that caused it to stop working on localhost. All I did was modify firebase.json like so to add host

 "emulators": {
        "auth": {
            "port": 9099,
            "host": "127.0.0.1"
        },
        "functions": {
            "port": 5001,
            "host": "127.0.0.1"
        },
        "firestore": {
            "port": 8080,
            "host": "127.0.0.1"
        },
        "hosting": {
            "port": 5001
        },
        "ui": {
            "enabled": true
        },
        "pubsub": {
            "port": 8085,
            "host": "127.0.0.1"
        },
        "storage": {
            "port": 9199,
            "host": "127.0.0.1"
        }
    }

Worked for me, I also needed to change all my env variables to not use localhost: process.env.FIREBASE_DATABASE_EMULATOR_HOST = '127.0.0.1:9000';

ghost commented 2 years ago

Downgrading to node 16 resolved the issue for me. Arch Linux (for search engines)

yuchenshi commented 2 years ago

Closing since downgrading to Node.js 16 seems to be a good workaround. Feel free to comment if you have more information or if this problem still persists when Node.js 18 becomes the new stable release.

msrumon commented 2 years ago

Confirmed that https://github.com/firebase/firebase-tools/issues/2379#issuecomment-951884721 works. I'm on Windows 10 Pro machine with Node.js v17.2.0.

svenjacobs commented 2 years ago

I'm having the same timeout issue with Node 17. In case you are using Volta for managing your Node versions, you can use the volta command for running firebase with a specific Node version, for example:

volta run --node 16.14.0 firebase emulators:start
ninest commented 2 years ago

I found this issue after Googling the error:

error - Error: Error while making request: connect ECONNREFUSED ::1:9099. Error code: ECONNREFUSED

https://github.com/firebase/firebase-tools/issues/2379#issuecomment-951884721 sent me in the right direction. All I had to do was change localhost to 127.0.0.1 in the environment variables

FIREBASE_AUTH_EMULATOR_HOST = "127.0.0.1:9099"

But my firebase.json is still the same and there seem to be no issues:

{
  "emulators": {
    "auth": {
      "port": 9099
    },
    "ui": {
      "enabled": true,
      "port": 9098
    }
  }
}

(I am only using Firebase and the emulator for authentication)

ktsin commented 2 years ago

Just FYI same behavior on Windows machine with latest firebase tool

node -v
v18.5.0
firebase --version
11.2.2

Adding "host" : "127.0.0.1" allowed to start emulator, but UI still not working. Message below appears each time i'm trying to reach emulator's UI.

[2022-07-13T12:51:39.938Z] u [FetchError]: request to http://localhost:4400/emulators failed, reason: connect ECONNREFUSED ::1:4400
    at ClientRequest.<anonymous> (C:\Users\User\.cache\firebase\emulators\ui-v1.7.0\server.bundle.js:326:16909)
    at ClientRequest.emit (node:events:537:28)
    at Socket.socketErrorListener (node:_http_client:465:9)
    at Socket.emit (node:events:537: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'
}
 {"metadata":{"emulator":{"name":"ui"},"message":"u [FetchError]: request to http://localhost:4400/emulators failed, reason: connect ECONNREFUSED ::1:4400\n    at ClientRequest.<anonymous> (C:\\Users\\User\\.cache\\firebase\\emulators\\ui-v1.7.0\\server.bundle.js:326:16909)\n    at ClientRequest.emit (node:events:537:28)\n    at Socket.socketErrorListener (node:_http_client:465:9)\n    at Socket.emit (node:events:537:28)\n    at emitErrorNT (node:internal/streams/destroy:151:8)\n    at emitErrorCloseNT (node:internal/streams/destroy:116:3)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {\n  type: 'system',\n  errno: 'ECONNREFUSED',\n  code: 'ECONNREFUSED'\n}\n"}}

[UPDATE] Extra strange, but I can reach http://localhost:4400/emulators via browser and see list of configured "nodes". image

bkendall commented 2 years ago

(internal bug reference: b/172852315)

christhompsongoogle commented 2 years ago

Hi everyone, there have been some changes recently to the IP resolution logic - if anyone is still hitting this issue please leave a comment.

VikashFluxon commented 2 years ago

I faced similar error where it failed to initialise the ports and faced a timeout while checking for it to be active. I checked the logs and it had the following message. 'auth: Port 5002 is available on 127.0.0.1 but not ::1. This may cause issues with some clients.' It suggested me to change the port and try. I did and it worked but I am still curious as to why it did not work with 500X ports.

This started happening after the latest firebase release. https://github.com/firebase/firebase-tools/releases/tag/v11.14.4

christhompsongoogle commented 2 years ago

Hi VikashFluxon, please open a new ticket with the relevant repro case(s) and logs.

mono-sudo2 commented 1 year ago

Hi everyone! I ran into this issue and am unsure how to fix it. I hope this is the right place to post this.

My Console Output:

i emulators: Starting emulators: firestore i firestore: Importing data from ...location/firestore/backup/backup/backup_1.overall_export_metadata ⚠ 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 emulators: Shutting down emulators. i firestore: Stopping Firestore Emulator i hub: Stopping emulator hub

Error: TIMEOUT: Port 8080 on 127.0.0.1 was not active within 60000ms

My firebase-export-metadata.json: { "version": "11.16.1", "firestore": { "version": "1.15.1", "path": "backup/backup", "metadata_file": "backup/backup/backup_1.overall_export_metadata" } }

I believe the cause to be the size of the dataset (it's about 7GB). I was trying to find a way to increase the timeout time, but couldn't find it. Maybe someone here could help me out?

Thanks in advance!

christhompsongoogle commented 1 year ago

Is the problem reproducible with smaller sets of data? < 100MB type of size

ciriousjoker commented 1 year ago

Can't test with <100mb, but with 750mb it's still reproducible. Also, is there a way to increase the timeout? Idc if I have to wait an hour as long as it works. I'm just using the emulator to look at backups and afaik there is no way to "shrink" them by filtering for only the collections I'm interested in.

EDIT: So apparently, when running without export JAVA_TOOL_OPTIONS="-Xmx4g", it will throw a heap error. When setting the JAVA_TOOL_OPTIONS variable to 4g, it would throw no error and time out. When running the jar directly, it will throw a heap error.

Solution: Increase to 8g, no more timeout. Probably doesn't scale very well, but for my usecase with 750gb it seems to work...

IncognitoGK9 commented 1 year ago

Is there a step by step known documentation on how to configure firebase emulator to work with either the android/ios emulator or read devices, for me, NONE of the above has ever worked for me. The only thing which works is using the firebase emulators with web (Chrome or Edge) or connecting directly to Firebase live. Those works like charm. But connecting android emulator with firebase emulators or real device with firebase emulator has NEVER worked despite all those snip steps. Is there a known step by step procedure on this, this will be useful. The documentation on Firebase seems to miss a lot, and even the codelabs still do not point exactly what is to be done when, where and how. To me it seems it is all guesswork.