How to fix auth/invalid-phone-number in Firebase

FirebaseBEGINNERMEDIUMUpdated Dec 22, 2025· 172 views

Firebase rejected your phone number format. Phone numbers must be in E.164 format with country code (e.g., +1 650-555-3434). Fix the format or use a valid test number during development.

Quick fix

Fixes auth/invalid-phone-number

try {
  await firebase.auth().signInWithPhoneNumber(
    "+1 650-555-3434",
    appVerifier
  );
} catch (error) {
  if (error.code === "auth/invalid-phone-number") {
    console.error("Invalid phone format. Use: +[country][number]");
  }
}
  1. Format the phone number in E.164 format
  2. Validate the country code is correct
  3. Use test phone numbers during development
  4. Add error handling in your code
firebase — error
try {
await firebase.auth().signInWithPhoneNumber(
"+1 650-555-3434",
appVerifier
);
} catch (error) {
if (error.code === "auth/invalid-phone-number") {
console.error("Invalid phone format. Use: +[country][number]");
}
}
auth/invalid-phone-number

What this error means

The "auth/invalid-phone-number" error occurs when Firebase Authentication cannot parse the phone number you provided into the E.164 international format. E.164 is the standard format for phone numbers used globally: [+][country code][area code][subscriber number]. Firebase enforces this strict format to ensure phone authentication works consistently across different regions and carriers. The error may also occur if the phone number is missing required digits, has invalid characters, or doesn't match the expected length for the given country code.

Typical symptoms

  • Firebase returns "The format of the phone number provided is incorrect"
  • verifyPhoneNumber() or signInWithPhoneNumber() fails during phone authentication
  • App crashes with FirebaseAuthInvalidCredentialsException
  • Error code appears in verificationFailed callback
  • Phone sign-in flow cannot proceed

Common causes

  1. Phone number missing the leading "+" and country code (e.g., "5551234567" instead of "+1 555-123-4567")
  2. Phone number contains spaces, dashes, or other formatting characters that E.164 doesn't allow
  3. Phone number is too short or too long for the specified country code
  4. Phone number includes invalid characters like letters or special symbols
  5. Country code is incorrect or missing entirely
  6. Test phone number not registered in Firebase Console for testing

How to fix "auth/invalid-phone-number"

1Format the phone number in E.164 format

E.164 format is: [+][country code][phone number with no spaces or dashes]

Examples of correct formats:
- United States: +1 650-555-3434 → +16505553434
- United Kingdom: +44 7444 555 666 → +447444555666
- Germany: +49 30 123456 → +4930123456

Remove all spaces, dashes, parentheses, and other formatting characters. Keep only the "+" prefix and digits.

2Validate the country code is correct

Ensure you have the correct country code for the user's location. Country codes vary by nation:
- USA/Canada: +1
- UK: +44
- Germany: +49
- France: +33
- Australia: +61

Double-check the country code against the user's actual location. If unsure, ask the user to select their country in your app before submitting the phone number.

3Use test phone numbers during development

During development, Firebase allows you to register test phone numbers in the Firebase Console:

1. Open Firebase Console → Authentication → Sign-in method
2. Click on "Phone" provider
3. Expand "Phone numbers for testing"
4. Add a test phone number (e.g., +1 650-555-3434) with a test verification code (e.g., 123456)

When you use a registered test phone number, Firebase will not send an actual SMS. Instead, it will immediately verify with the code you specified.

4Add error handling in your code

Catch and handle the error properly to inform users:

JavaScript/Web:

javascript
try {
  await firebase.auth().signInWithPhoneNumber(
    "+1 650-555-3434",
    appVerifier
  );
} catch (error) {
  if (error.code === "auth/invalid-phone-number") {
    console.error("Invalid phone format. Use: +[country][number]");
  }
}

Flutter:

dart
await FirebaseAuth.instance.verifyPhoneNumber(
  phoneNumber: "+1 650-555-3434",
  verificationFailed: (FirebaseAuthException e) {
    if (e.code == "invalid-phone-number") {
      print("Please enter a valid phone number with country code.");
    }
  },
);

React Native:

javascript
try {
  await auth().signInWithPhoneNumber("+1 650-555-3434");
} catch (error) {
  if (error.code === "auth/invalid-phone-number") {
    setError("Phone number format is invalid");
  }
}
5Verify phone authentication is enabled

Ensure the Phone authentication provider is enabled in your Firebase project:

1. Go to Firebase Console
2. Select your project
3. Navigate to Authentication → Sign-in method
4. Look for "Phone" in the list
5. If it's disabled (greyed out), click it and toggle "Enable"
6. Click Save

Without enabling the Phone provider, all phone authentication requests will fail.

Advanced notes

Rate limiting: Firebase enforces SMS rate limits. If you exceed the quota (usually 15-20 SMS per user per hour during development), requests will be throttled. Use test phone numbers to avoid consuming your SMS quota during development. Some valid phone numbers may still fail if they belong to VOIP services or are known blocklisted numbers. In production, provide users with clear guidance on phone number format and allow them to choose their country from a dropdown to pre-fill the country code. Consider implementing client-side validation with a library like libphonenumber-js before sending to Firebase to catch formatting errors early and improve user experience.

Frequently asked questions

What does "auth/invalid-phone-number" mean?
164 international format. 164 is the standard format for phone numbers used globally: [+][country code][area code][subscriber number]. Firebase enforces this strict format to ensure phone authentication works consistently across different regions and carriers.
How do I fix "auth/invalid-phone-number"?
Firebase rejected your phone number format. Phone numbers must be in E.164 format with country code (e.g., +1 650-555-3434). Fix the format or use a valid test number during development.
What causes "auth/invalid-phone-number"?
Phone number missing the leading "+" and country code (e.g., "5551234567" instead of "+1 555-123-4567") Phone number contains spaces, dashes, or other formatting characters that E.164 doesn't allow Phone number is too short or too long for the specified country code
Is the "auth/invalid-phone-number" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading