Skip to content
Latchkey

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

  1. Wrap tests in firebase emulators:exec so the emulators start and stop cleanly.
  2. It shuts the emulators down when the command finishes, freeing ports.
  3. Avoid leaving a background emulators:start running 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:exec so 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →