Started firebase project emulators (which uses cloud functions and firestore) with below command
firebase emulators:start
It runs successfully and gives me a path to connect to the functions and shows a local host url for firestore too.
Then, to execute my jest tests, ran the below command
firebase emulators:exec --only firestore jest
As per the documentation, to connect to local firstore, we need to use exec. But its throwing below error.
i emulators: Starting emulators: firestore
⚠ emulators: emulator hub unable to start on port 4400, starting on 4401
✔ hub: emulator hub started at http://localhost:4401
i Shutting down emulators.
i Stoppping emulator hub
⚠ Port 8080 is not open on localhost, could not start firestore emulator.
i To select a different host/port for the emulator, update your "firebase.json":
{
// ...
"emulators": {
"firestore": {
"host": "HOST",
"port": "PORT"
}
}
}
i Shutting down emulators.
Error: Could not start firestore emulator, port taken.
This error is thrown everytime when I run exec command. Can someone point out what could be wrong?
Edit: Logs from firebase emulators:start
firebase emulators:start
i emulators: Starting emulators: functions, firestore, hosting, pubsub
✔ hub: emulator hub started at http://localhost:4400
⚠ Your requested "node" version "8" doesn't match your global version "10"
✔ functions: functions emulator started at http://localhost:5001
i firestore: Serving ALL traffic (including WebChannel) on http://localhost:8080
⚠ firestore: Support for WebChannel on a separate port (8081) is DEPRECATED and will go away soon. Please use port above instead.
i firestore: firestore emulator logging to firestore-debug.log
✔ firestore: firestore emulator started at http://localhost:8080
i firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080
i hosting[website]: Serving hosting files from: public
✔ hosting[website]: Local server: http://localhost:5000
i hosting[admin]: Serving hosting files from: public
✔ hosting[admin]: Local server: http://localhost:5005
i hosting[b2b]: Serving hosting files from: public
✔ hosting[b2b]: Local server: http://localhost:5006
i hosting[b2c]: Serving hosting files from: public
✔ hosting[b2c]: Local server: http://localhost:5007
i hosting[sdk]: Serving hosting files from: public
✔ hosting[sdk]: Local server: http://localhost:5008
✔ hosting: hosting emulator started at http://localhost:5000
i pubsub: pubsub emulator logging to pubsub-debug.log
✔ pubsub: pubsub emulator started at http://localhost:8085
Update
With a fresh start also the mentioned error is shown. But killing the port made it work.
Added below in scipts part of package.json
"kill": "npx kill-port 5000 5001 8080 8085 4000 9229"
and run
npm run kill
Here all above listed ports aren't reqired. Just 8080 might work in your case but I have other ports too being used by the emulator.
lsof
command is not availalble on windows powershell.
A better cross-platform solution is: npx kill-port 8080
Type this in your terminal, where 8080 is your port number:
lsof -ti tcp:8080 | xargs kill
Reason: Failed quitting the previous firebase emulator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With