firebase/quickstart-nodejs

How do you set the port of the firestore emulator?

wichopy opened this issue · 4 comments

When I try the command firebase serve --only firestore --port 5001 it still runs on port 8080. Is there a way to configure the port?

EDIT:

Went through the firebase-tools repo and found this constants file. I guess this means we can't assign the port for the firestore emulator atm?
https://github.com/firebase/firebase-tools/blob/master/src/emulator/constants.js#L25

@wichopy thanks for the feedback. You're right that currently the --port argument only applies to the Hosting development server. Now that there are three local servers (Firestore, Functions, and Hosting) we clearly need to find a better way to pass in these arguments without conflicts.

My vote is to put them in firebase.json but I will let @ryanpbrewster chime in.

I have an PR open to add a --firestore-port flag for this purpose. Until that goes in, the only way to set the port is to directly execute the emulator JAR. By default it's installed to $HOME/.cache/firebase/emulators/, and it accepts a --port flag

Thanks @ryanpbrewster that will be a good work around for now.

This is now possible via firebase emulators:start --only firestore, which reads the port from firebase.json. The javascript-quickstart has an example of how to do this.

Be aware that you may have to modify some of your code if you change the port from the default of 8080. Setting FIRESTORE_EMULATOR_HOST should also work.