How can I shut down the local firebase emulators?
Solution 1
- Check which process is occupying the port
sudo lsof -i tcp:<port>
- Kill the process
kill -9 <process id>
Solution 2
according to this: https://github.com/firebase/firebase-tools/issues/1367 Ctrl+C
kills the emulators
Solution 3
If you don't want to have to check the port every time, you can stop command with below
kill -9 (lsof -t -i:5002 -i:5001)
(-i:xxxx are your running emulator ports in firebase.json.)
Moreover, I don't want to memorize this long command. So I made package.json script below.
"scripts": {
...
"stop": "lsof -t -i :5001 -i:5002 | xargs kill -9",
...
}
Solution 4
One cross-platform solution is to just run: npx kill-port 4000,8080,8085
Solution 5
If you wanna kill all firebase emulators you can easily do that by firing this command
$ lsof -t -i:8080 -i:9000 -i:9099 -i:9199 -i:9090 | xargs kill -9
When you don't want to type this long command each time I advise you to use a script in the package.json file
"scripts": {
"emulators:start": "firebase emulators:start",
"emulators:stop": "lsof -t -i:5001 -i:5002 -i:8080 -i:9000 -i:9099 -i:9199 -i:9090 | xargs kill -9"
}
One for starting your emulators and one for stopping, in case Ctr+C didn't stop the processes in the background.
Those are the default PORTS from the documentation page in firebase. You should also check your firebase.json file and replace the PORTS in the previous command if they are different.
user1447414
Updated on June 14, 2022Comments
-
user1447414 almost 2 years
Currently I initialise the firebase emulators with:
$ firebase emulators:start
After some time working on it I want to stop it. How can I then stop the emulators?
-
ra9r over 3 yearsI have found that if you exit VSCode without shutting down the emulators first it can remain running and without the above commands, you will need to restart the computer to be able to restart the emulators. Thank you for sharing @xmkevinchen
-
ThdK over 3 yearsFor windows: stackoverflow.com/a/39633428/681803
-
perepm over 3 years@ra9r on linux the process is called java. If you kill it you won't need to restart your computer.
-
user3875913 about 3 yearsthis was it for me, though --no-run-if-empty is bogus on macOS
-
cyber_angel about 3 yearsI'm flabbergasted there is no shutdown command...this is an insane workflow.
-
Jeff Neet over 2 yearsThis seems like such an obvious feature to include in a command
firebase emulators:stop
or similar, it makes me think I'm using the tool wrong. Is the normal workflow to start up the emulators and leave them running in the background while developing for long periods of time? -
Alberto Oliveira about 2 yearsFaster option, and work in windows and Linux
-
Johann about 2 yearsNope. Doesn't work on a MacBook.
-
monsto about 2 yearsNothing like a little automation to simplify your day.
-
monsto about 2 years@JeffNeet that's the way I use it. I fire up the function/firestore emulators and work on event functions and db triggers. Sometimes it completely blows out and stops with an error leaving the process running which is when I need the answer below by user kazuwombat. Generally tho, 2x Ctrl-C is enough.