How to run the firebase emulator with a specific host address?
Solution 1
I had to use another port, like 8000
, instead of 8080
for firestor entry in firebase.json
so the command could run.
firebase emulators:start --inspect-functions --export-on-exit ./test_data/ --import ./test_data/
Taken from this github issue. Also, using 0.0.0.0
will make firebase emulator use localhost or the ip address of the machine in the local network.
Although lsof -i :8080
doesn’t return any result indicating there is an application using the port 8080
Solution 2
I would suggest removing the: "host": "0.0.0.0",
from firestore.json. Firebase Documentation
This command helped me kill the app running on port 8080:
lsof -ti tcp:8080 | xargs kill
joe_inz
Updated on January 01, 2023Comments
-
joe_inz over 1 year
I'm trying to connect my flutter app running on a physical device with the firebase emulator on the local machine, followed these steps in this SOF to do so, but when running this command
firebase emulators:start --inspect-functions --export-on-exit ./test_data/ --import ./test_data/
with this configuration in
firebase.json
:{ "functions": { "predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run build" ], "source": "functions" }, "firestore": { "rules": "firestore.rules", "indexes": "firestore.indexes.json" }, "storage": { "rules": "storage.rules" }, "emulators": { "auth": { "host": "0.0.0.0", "port": 9099 }, "functions": { "host": "0.0.0.0", "port": 5001 }, "firestore": { "host": "0.0.0.0", "port": 8080 }, "storage": { "host": "0.0.0.0", "port": 9199 }, "ui": { "enabled": true } } }
it results in this output:
i emulators: Starting emulators: auth, functions, firestore, storage ⚠ functions: You are running the functions emulator in debug mode (port=9229). This means that functions will execute in sequence rather than in parallel. ⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: database, hosting, pubsub ✔ functions: Using node@14 from local cache. i emulators: Shutting down emulators. i functions: Stopping Functions Emulator i hub: Stopping emulator hub ⚠ firestore: Port 8080 is not open on 0.0.0.0, could not start Firestore Emulator. ⚠ firestore: To select a different host/port, specify that host/port in a firebase.json config file: { // ... "emulators": { "firestore": { "host": "HOST", "port": "PORT" } } } i emulators: Shutting down emulators.
and this error:
Error: Could not start Firestore Emulator, port taken.
Obvious solution
Kill whatever app using the port 8080, more likely it is the firestore emulator of the pervious session, from this SOF. After killing the app and running the command again, the same error occurs.
Note
even using my machine address in the local network instead of
0.0.0.0
did not work and results in the same output. -
joe_inz over 2 yearsi did kill the app that was using the port, but the error persists. also, removing the
"host": "0.0.0.0"
will default it to localhost i believe which means it will not work when running the app on a physical device.