Skip to content

Can't run multiple emulators: Error: listen EADDRINUSE: address already in use :::9005 #5418

Closed
@nfarina

Description

@nfarina

We often run multiple development servers for Firebase Functions so we can quickly test code against two separate environments: one that operates on our production Firestore DB, and another that operates on an emulated Firestore DB.

This has been working well for a long time! But some recent update has caused it to break.

It appears that the Functions emulator "discovers" what functions the code is exporting at runtime by starting up a little server on port 9005 and then exiting. This is fine, but when multiple instances of the emulator are running, and your function code is modified, they both try to open the same port at the same time and then crash (well, they don't crash but the changes are not picked up and errors are printed).

I did see the same error in #4684 but it doesn't appear related.

Environment info

firebase-tools: 11.20.0
Platform: MacOS

Test case

Here's a minimal project reproducing the problem.

Steps to reproduce

Run both npm run serve:1 and npm run serve:2 from the functions folder in a separate terminal.

Then make a trivial modification to index.js, like add another exclamation mark to "Hello from Firebase!".

Expected behavior

Both servers should pick up the change to index.js without crashing.

Actual behavior

You should see the EADDRINUSE printed from one of the two servers as both try to simultaneously spin up little servers to discover functions.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions