How to fix messaging/mismatched-sender-id in Firebase

FirebaseINTERMEDIATEHIGHUpdated Dec 22, 2025Β· 190 views

The "messaging/mismatched-sender-id" error occurs when the Firebase Cloud Messaging (FCM) Sender ID used by your client app does not match the Sender ID associated with the Firebase project you are using to send messages. This typically happens when registration tokens were generated from a different Firebase project than the one your server is using to send push notifications.

Quick fix

Fixes messaging/mismatched-sender-id

import { initializeApp } from "firebase/app";
import { getMessaging, getToken } from "firebase/messaging";

const firebaseConfig = {
  apiKey: "YOUR_API_KEY",
  projectId: "YOUR_PROJECT_ID",  // This must match your server project
  messagingSenderId: "YOUR_SENDER_ID",  // Verify this matches Firebase Console
  appId: "YOUR_APP_ID",
};

const app = initializeApp(firebaseConfig);
const messaging = getMessaging(app);

getToken(messaging, {
  vapidKey: "YOUR_VAPID_KEY"
}).then(token => {
  console.log("Registration token:", token);
});
  1. Verify your Firebase project Sender ID
  2. Check your client app Firebase configuration
  3. Verify server credentials match client project
  4. Re-generate registration tokens with correct configuration
firebase β€” error
import { initializeApp } from "firebase/app";
import { getMessaging, getToken } from "firebase/messaging";
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
projectId: "YOUR_PROJECT_ID", // This must match your server project
messagingSenderId: "YOUR_SENDER_ID", // Verify this matches Firebase Console
appId: "YOUR_APP_ID",
};
const app = initializeApp(firebaseConfig);
const messaging = getMessaging(app);
getToken(messaging, {
vapidKey: "YOUR_VAPID_KEY"
}).then(token => {
console.log("Registration token:", token);
});
messaging/mismatched-sender-id

What this error means

The "messaging/mismatched-sender-id" error indicates that the Firebase Cloud Messaging registration token on the client was generated from a Firebase project that is different from the Firebase project credentials being used on your server to send the push notification. The Sender ID identifies your app to Firebase Cloud Messaging when it requests a registration token. If the client app and server credentials belong to different Firebase projects, the server cannot send messages to tokens generated by the client, resulting in this error.

Typical symptoms

  • Push notification sending fails with "messaging/mismatched-sender-id" error
  • Messages fail to deliver even though registration tokens appear valid
  • Admin SDK reports SenderId mismatch when attempting to send notifications
  • Notifications work on some devices or in some environments but fail in others
  • After migrating from GCM to FCM, push notifications stop working entirely
  • Server-side logs show "sender id does not match registration token" errors

Common causes

  1. Client app is configured with a different Firebase project than the server sending messages
  2. Server is using service account credentials from a different Firebase project than the client
  3. Migration from GCM to FCM where the old GCM project and new FCM project have different Sender IDs
  4. Copy-pasted registration token from a different Firebase project or environment
  5. Multiple Firebase projects in the same app with tokens generated from the wrong project
  6. Client app re-initialized with different Firebase config after token generation

How to fix "messaging/mismatched-sender-id"

1Verify your Firebase project Sender ID

Find your Sender ID in the Firebase Console:

1. Go to [Firebase Console](https://console.firebase.google.com)
2. Select your project
3. Navigate to Project Settings (gear icon) > Cloud Messaging tab
4. Your Sender ID is displayed prominently (it's the same as your Project Number)
5. Note this Sender ID for comparison with your client configuration

You'll need this to verify your client app is using the correct project.

2Check your client app Firebase configuration

Ensure your client app is initialized with the correct Firebase project:

Web/JavaScript (using SDK):

javascript
import { initializeApp } from "firebase/app";
import { getMessaging, getToken } from "firebase/messaging";

const firebaseConfig = {
  apiKey: "YOUR_API_KEY",
  projectId: "YOUR_PROJECT_ID",  // This must match your server project
  messagingSenderId: "YOUR_SENDER_ID",  // Verify this matches Firebase Console
  appId: "YOUR_APP_ID",
};

const app = initializeApp(firebaseConfig);
const messaging = getMessaging(app);

getToken(messaging, {
  vapidKey: "YOUR_VAPID_KEY"
}).then(token => {
  console.log("Registration token:", token);
});

Android (Firebase config):

xml
<!-- Check your google-services.json file contains the correct project ID -->
<!-- The Sender ID in google-services.json must match your Firebase project -->

Verify the projectId and messagingSenderId match your Firebase Console settings.

3Verify server credentials match client project

Ensure your backend server uses credentials from the same Firebase project:

Node.js Admin SDK:

javascript
const admin = require("firebase-admin");
const serviceAccount = require("./serviceAccountKey.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  // Note: Do NOT override the project ID. Admin SDK uses the project ID
  // from your service account JSON file. This MUST match your client project.
});

// Verify the project ID
console.log("Server using project:", admin.app().options.projectId);

// Send a message
admin.messaging().sendToDevice(registrationToken, message)
  .catch(error => {
    if (error.code === "messaging/mismatched-sender-id") {
      console.log("Client and server using different Firebase projects!");
    }
  });

Verification: The project_id in your serviceAccountKey.json must match the project ID shown in your client's Firebase config.

4Re-generate registration tokens with correct configuration

If you've corrected your Firebase configuration, you need to generate new registration tokens:

Web/JavaScript:

javascript
import { getMessaging, getToken, deleteToken } from "firebase/messaging";

const messaging = getMessaging();

// Delete old token (optional, forces new token generation)
await deleteToken(messaging);

// Request new token with fresh configuration
const token = await getToken(messaging, {
  vapidKey: "YOUR_VAPID_KEY"
});

console.log("New registration token:", token);

// Send this new token to your server to replace the old one
await fetch("/api/update-token", {
  method: "POST",
  body: JSON.stringify({ token })
});

Android:

java
import com.google.firebase.messaging.FirebaseMessaging;

// Firebase automatically generates a new token when re-initialized
// with correct google-services.json
FirebaseMessaging.getInstance().getToken()
  .addOnCompleteListener(task -> {
    if (!task.isSuccessful()) {
      Log.w(TAG, "Fetching FCM registration token failed", task.getException());
      return;
    }
    String token = task.getResult();
    Log.d(TAG, "New FCM Token: " + token);
  });

Store this new token on your server, replacing the old mismatched token.

5Test message sending with the new token

Verify that messages now send successfully:

Node.js test:

javascript
const admin = require("firebase-admin");

const message = {
  notification: {
    title: "Test Notification",
    body: "If you see this, sender ID is now matched!"
  },
  token: newRegistrationToken  // Use the newly generated token
};

admin.messaging().send(message)
  .then(response => {
    console.log("Message sent successfully:", response);
  })
  .catch(error => {
    if (error.code === "messaging/mismatched-sender-id") {
      console.log("Still mismatched! Check configuration again.");
    } else {
      console.log("Error sending message:", error);
    }
  });

If the message sends successfully (no error), your Sender ID mismatch is resolved.

6Handle GCM to FCM migration if applicable

If you're migrating from Google Cloud Messaging (GCM) to Firebase Cloud Messaging:

1. Identify old vs new tokens: Old GCM tokens belong to your previous GCM project; new FCM tokens belong to your new FCM project
2. Sender ID difference: GCM and FCM projects have different Sender IDs, which causes mismatches
3. Migration strategy:
- Keep track of which tokens are from the old GCM project and which are from new FCM
- Send GCM messages using old credentials (if still supporting GCM)
- Send FCM messages only to new FCM tokens
- Encourage users to update their apps to generate new FCM tokens
4. Deprecate old tokens: Over time, transition all users to the new Firebase project

Consider keeping both GCM and FCM endpoints active during transition period.

Advanced notes

The Sender ID is derived from your Firebase project number and is distinct from the Project IDβ€”they are different values. When using Pub/Sub based messaging flows, ensure your subscription credentials also use the same Firebase project. If you're using third-party notification services (like Batch, Airship, or Pushwoosh), verify their Firebase integration is connected to the correct project. In development environments using Firebase Emulator, ensure both client and emulator are configured with the same project ID. The error message may also appear as "SenderId mismatch" or "mismatched-sender-id" depending on your SDK version.

Frequently asked questions

What does "messaging/mismatched-sender-id" mean?
The "messaging/mismatched-sender-id" error indicates that the Firebase Cloud Messaging registration token on the client was generated from a Firebase project that is different from the Firebase project credentials being used on your server to send the push notification. The Sender ID identifies your app to Firebase Cloud Messaging when it requests a registration token. If the client app and server credentials belong to different Firebase projects, the server cannot send messages to tokens generated by the client, resulting in this error.
How do I fix "messaging/mismatched-sender-id"?
The "messaging/mismatched-sender-id" error occurs when the Firebase Cloud Messaging (FCM) Sender ID used by your client app does not match the Sender ID associated with the Firebase project you are using to send messages. This typically happens when registration tokens were generated from a different Firebase project than the one your server is using to send push notifications.
What causes "messaging/mismatched-sender-id"?
Client app is configured with a different Firebase project than the server sending messages Server is using service account credentials from a different Firebase project than the client Migration from GCM to FCM where the old GCM project and new FCM project have different Sender IDs
Is the "messaging/mismatched-sender-id" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading