Firebase "Could not start emulator, port taken" in CI
The emulator tried to bind a port that is already in use. On a runner this is usually a previous emulator process that did not shut down, or a port that another service in the job already holds.
What this error means
Starting the emulators fails with "Error: Could not start Firestore Emulator, port taken. Please ensure that the port is not being used by another process."
firebase
Error: Could not start Firestore Emulator, port taken. Please ensure that the port 8080 is not being used by another process.Common causes
A leftover emulator process holds the port
A prior emulator run in the same job did not exit and still owns the port.
The port collides with another service
The default emulator port overlaps a service already started in the CI job.
How to fix it
Run the job under emulators:exec
- Wrap tests in
firebase emulators:execso the emulators start and stop cleanly. - It shuts the emulators down when the command finishes, freeing ports.
- Avoid leaving a background
emulators:startrunning across steps.
Terminal
firebase emulators:exec --only firestore "npm test"Assign a free port in firebase.json
Pin emulator ports explicitly so they do not collide with other services in the job.
firebase.json
{
"emulators": { "firestore": { "port": 8085 } }
}How to prevent it
- Use
emulators:execso emulators stop after the command. - Pin emulator ports away from other services in the job.
- Do not run multiple emulator instances on the same port.
Related guides
Firebase "emulators:exec ... exited with code 1" in CIFix Firebase "Script exited with code 1" from firebase emulators:exec in CI - the wrapped command (usually yo…
Firebase "Cannot understand what targets to deploy/serve" in CIFix Firebase "Error: Cannot understand what targets to deploy/serve" in CI - firebase.json has no matching pr…
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…