Firebase "emulators:exec ... exited with code 1" in CI
The emulators started fine; the command you passed to emulators:exec returned a non-zero exit code. emulators:exec forwards that exit code, so the failure is in your test or script, not the emulator itself.
What this error means
A CI step fails with "Script exited with code 1" or "emulators:exec: Script exited with non-zero code" after the emulators booted.
firebase
i emulators: Shutting down emulators.
Error: Script exited with code 1Common causes
The wrapped tests failed
Your test command returned 1, which emulators:exec propagates as its own exit code.
The tests target the wrong emulator host
If the app connects to production instead of the emulator, tests fail against unexpected data.
How to fix it
Read your command output, not the emulator log
- Scroll to the test output printed before the shutdown line.
- Fix the failing test or script.
- Confirm the app points at the emulator host and ports.
Terminal
firebase emulators:exec --only firestore,auth "npm test"Point the SDK at the emulators
Set the emulator host env vars so your code connects to the emulator during the run.
.github/workflows/ci.yml
env:
FIRESTORE_EMULATOR_HOST: 127.0.0.1:8080
FIREBASE_AUTH_EMULATOR_HOST: 127.0.0.1:9099How to prevent it
- Treat a non-zero exit as a real test failure, not an emulator bug.
- Set emulator host env vars so tests hit the emulator.
- Keep emulator ports consistent between config and env vars.
Related guides
Firebase "Could not start emulator, port taken" in CIFix Firebase "Error: Could not start X emulator, port taken" in CI - the emulator port is already in use, oft…
Firebase "Compilation error in firestore.rules" in CIFix Firebase "Error: Compilation error in firestore.rules" in CI - the security rules file has a syntax error…
Firebase "Invalid argument ... rules" in CIFix Firebase "Error: HTTP Error: 400, Invalid argument" when deploying rules in CI - the rules request was re…