0
0
Firebasecloud~5 mins

Firebase Emulator Suite - Commands & Configuration

Choose your learning style9 modes available
Introduction
The Firebase Emulator Suite lets you run Firebase services on your computer. This helps you build and test your app safely without touching real data or spending money.
When you want to test your app's database changes without affecting live data.
When you need to develop authentication flows without creating real user accounts.
When you want to try Cloud Functions locally before deploying them.
When you want to simulate Firestore or Realtime Database behavior offline.
When you want to run integration tests that involve multiple Firebase services.
Config File - firebase.json
firebase.json
{
  "emulators": {
    "auth": {
      "port": 9099
    },
    "firestore": {
      "port": 8080
    },
    "functions": {
      "port": 5001
    },
    "ui": {
      "enabled": true,
      "port": 4000
    }
  }
}

This file configures which Firebase emulators to run and their ports.

auth: Runs the Authentication emulator on port 9099.

firestore: Runs the Firestore emulator on port 8080.

functions: Runs the Cloud Functions emulator on port 5001.

ui: Enables the Emulator Suite UI on port 4000 for easy management.

Commands
Starts all Firebase emulators defined in firebase.json so you can test your app locally.
Terminal
firebase emulators:start
Expected OutputExpected
i emulators: Starting emulators: auth, firestore, functions, ui ✔ functions: Using node@16 from host. ✔ firestore: Firestore Emulator logging to firestore-debug.log ✔ auth: Authentication Emulator logging to auth-debug.log ✔ ui: Emulator UI logging to ui-debug.log ✔ All emulators started, it is now safe to connect your app.
Runs your Cloud Functions code locally in the emulator, then deploys only functions to Firebase if tests pass.
Terminal
firebase emulators:exec "firebase deploy --only functions"
Expected OutputExpected
i emulators: Starting emulators: functions ✔ functions: Using node@16 from host. ✔ functions: Emulator started at http://localhost:5001 ✔ functions: Deployment complete. ✔ All emulators stopped.
Stops all running Firebase emulators to free up your computer's resources.
Terminal
firebase emulators:stop
Expected OutputExpected
✔ All emulators stopped.
Key Concept

If you remember nothing else from this pattern, remember: The Firebase Emulator Suite lets you safely build and test your app locally without touching live data.

Common Mistakes
Trying to connect your app to the real Firebase services while the emulator is running.
Your app won't use the emulator and may change live data or fail if credentials differ.
Configure your app to connect to the local emulator endpoints during development.
Not defining the emulators and their ports in firebase.json before starting.
The emulator won't start or will use default ports that might conflict with other services.
Always set up firebase.json with the emulators you want and their ports.
Leaving emulators running after finishing development.
Emulators consume system resources and may cause port conflicts later.
Run 'firebase emulators:stop' to cleanly shut down all emulators.
Summary
Create a firebase.json file to configure which emulators to run and their ports.
Use 'firebase emulators:start' to launch all configured emulators for local testing.
Stop emulators with 'firebase emulators:stop' when done to free resources.