Skip to content

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

Closed

Description

@dave-k

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

Activity

  1. samtstern commented on Jun 19, 2020

    @samtstern
    Contributor

    @dave-k when you say "unchanged project" do you mean this was working before and has since stopped? I haven't seen an error like this on macOS yet, could you try two things:

    1. I don't think anyone on our team is using Node 14 yet, most of us are on 12 or below. Does changing your Node version change anything?
    2. If you change the host for the Firestore emulator to 0.0.0.0 instead of localhost does that change anything? You can set this in firebase.json alongside the port.
  2. samtstern commented on Jun 19, 2020

    @samtstern
    Contributor

    Oh also I'm gonna transfer this issue over to the Firebase CLI repo.

  3. dave-k commented on Jun 20, 2020

    @dave-k
    Author

    @samtstern Unchanged i.e. no changes made to the tests.

    1. node v10.21.0
    2. host: 0.0.0.0

    Same Timeout error: [error] Error: TIMEOUT: Port 8080 on 0.0.0.0 was not active within 30000ms
    firebase-debug.log

    firebase.json

    {
      "firestore": {
        "rules": "firestore.rules"
      },
      "emulators": {
        "firestore": {
          "host": "0.0.0.0",
          "port": 8080
        }
      }
    }
    

    package.json

    {
      "name": "cloud-firestore-emulator-javascript-quickstart",
      "version": "1.0.2",
      "description": "Cloud Firestore emulator testing",
      "scripts": {
        "format": "prettier --write **/*.js",
        "test": "mocha --timeout=10000"
      },
      "devDependencies": {
        "@firebase/testing": "^0.20.3",
        "mocha": "5.2.0",
        "prettier": "1.15.2"
      }
    }
    
  4. added and removed
    Needs: Author Feedback
    on Jun 20, 2020
  5. samtstern commented on Jun 22, 2020

    @samtstern
    Contributor

    @dave-k thanks for trying hose things ... I am still pretty stumped on this issue.

    Could you try running the Firestore emulator JAR directly and see if it works for you:

    java -jar ~/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar
    

    The exact version of the jar may vary but you should have a cloud-firestore-emulator-*.jar in that location. You can also pass --port=<number> if you don't want to use 8080.

  6. added
    Needs: Author Feedback
    and removed on Jun 22, 2020
  7. dave-k commented on Jun 22, 2020

    @dave-k
    Author

    @samtstern

    $ java -jar ~/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.4.jar
    API endpoint: http://localhost:8080
    If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:
    
       export FIRESTORE_EMULATOR_HOST=localhost:8080
    
    Dev App Server is now running.
    
  8. added and removed
    Needs: Author Feedback
    on Jun 22, 2020
  9. 52 remaining items

  10. msrumon commented on Jan 3, 2022

    @msrumon

    Confirmed that #2379 (comment) works. I'm on Windows 10 Pro machine with Node.js v17.2.0.

  11. svenjacobs commented on Apr 13, 2022

    @svenjacobs

    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
    
  12. ninest commented on Jun 4, 2022

    @ninest

    I found this issue after Googling the error:

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

    #2379 (comment) 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)

  13. ktsin commented on Jul 13, 2022

    @ktsin

    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

  14. bkendall commented on Jul 18, 2022

    @bkendall
    Contributor

    (internal bug reference: b/172852315)

  15. christhompsongoogle commented on Oct 13, 2022

    @christhompsongoogle
    Contributor

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

  16. VikashFluxon commented on Oct 21, 2022

    @VikashFluxon

    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

  17. christhompsongoogle commented on Oct 24, 2022

    @christhompsongoogle
    Contributor

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

  18. mono-sudo2 commented on Nov 23, 2022

    @mono-sudo2

    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!

  19. christhompsongoogle commented on Nov 23, 2022

    @christhompsongoogle
    Contributor

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

  20. ciriousjoker commented on Jun 14, 2023

    @ciriousjoker

    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...

  21. IncognitoGK9 commented on Sep 14, 2023

    @IncognitoGK9

    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.

  22. added a commit that references this issue on Aug 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions