Port 8080 is not open on localhost, could not start Firestore Emulator. (How to terminate Firebase emulator)
Or, if you tried to start the emulator with only functions, I could be faced with this error.
error: port 5000 is not open, could not start functions emulator
This error is because of the failed quitting from firebase emulator. You already have the process of previous firebase emulator.
For a new start, you have to find and stop the previous process.
Original Error Thread
firebase emulators:start --inspect-functions
Debugger listening on ws://127.0.0.1:55442/7f867690-a2b9-4197-9a00-5c588a9fc6e7
For help, see: https://nodejs.org/en/docs/inspector
i emulators: Starting emulators: functions, firestore, hosting
⚠ 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, pubsub
⚠ Your requested "node" version "10" doesn't match your global version "14"
i emulators: Shutting down emulators.
i functions: Stopping Functions Emulator
i hub: Stopping emulator hub
⚠ firestore: Port 8080 is not open on localhost, could not start Firestore Emulator.
⚠ firestore: To select a different host/port, specify that host/port in a firebase.json config file:
i emulators: Shutting down emulators.Error: Could not start Firestore Emulator, port taken.Having trouble? Try firebase [command] --help
Waiting for the debugger to disconnect...
~ lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 5676 fredriccliver 129u IPv6 0xfff21bfd3e63ceb1 0t0 TCP localhost:http-alt (LISTEN)
java 5676 fredriccliver 138u IPv6 0xfff21bfd41959211 0t0 TCP localhost:65262->localhost:http-alt (ESTABLISHED)
java 5676 fredriccliver 139u IPv6 0xfff21bfd3f8195d1 0t0 TCP localhost:http-alt->localhost:65262 (ESTABLISHED)
This command will find a specific process which is running on the port 8080. and you can find the PID on the list.
~ ps ax | grep 5676
5676 ?? Ss 0:07.26 /usr/bin/java -Duser.language=en -jar /Users/fredriccliver/.cache/firebase/emulators/cloud-firestore-emulator-v1.11.7.jar --host localhost --port 8080 --functions_emulator localhost:5001
10537 s003 S+ 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn 5676
This command will help you find the original execution command what had opened that process.
Not you could find whether that process is firebase emulator. As you can see, that is firebase emulator.
~ kill 5676
And so, kill the process with PID matched with the emulator.
If you execute ps command again,
~ ps ax | grep 5676
10657 s003 S+ 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn 5676
There is not an emulator process no more
Collapsing into one command
~ lsof -ti tcp:8080 | xargs kill