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

FirebaseBEGINNERLOWUpdated Dec 22, 2025ยท 184 views

The auth/missing-phone-number error occurs when calling Firebase phone authentication methods without providing a valid phone number. This is thrown when the phone number parameter is missing or not passed to signInWithPhoneNumber or verifyPhoneNumber.

Quick fix

Fixes auth/missing-phone-number

const phoneNumber = userInput.trim();

if (!phoneNumber || phoneNumber.length === 0) {
  console.error('Phone number is required');
  setError('Please enter a valid phone number');
  return;
}

try {
  const confirmationResult = await signInWithPhoneNumber(
    auth,
    phoneNumber
  );
} catch (error) {
  console.error('Authentication failed:', error.code);
}
  1. Validate phone number input before authentication
  2. Include country code in phone number format
  3. Enable Phone Number authentication in Firebase Console
  4. Handle the error with proper error checking
firebase โ€” error
const phoneNumber = userInput.trim();
if (!phoneNumber || phoneNumber.length === 0) {
console.error('Phone number is required');
setError('Please enter a valid phone number');
return;
}
try {
const confirmationResult = await signInWithPhoneNumber(
auth,
phoneNumber
);
} catch (error) {
console.error('Authentication failed:', error.code);
}
auth/missing-phone-number

What this error means

Firebase Authentication throws the auth/missing-phone-number error when you attempt to authenticate a user via phone number but fail to provide a phone number string to the authentication method. This error indicates that the required phone number parameter is either missing, null, undefined, or empty in your authentication function call. Firebase requires a properly formatted phone number (including country code) to initiate phone-based authentication via SMS verification. This validation happens client-side in your application code before the request even reaches Firebase servers. It prevents invalid authentication attempts and helps maintain the integrity of your phone authentication flow.

Typical symptoms

  • Firebase authentication method throws "auth/missing-phone-number" error immediately
  • Phone sign-in form submission fails with error handling logic triggered
  • User receives error message about missing phone number despite entering data
  • Console shows error code "auth/missing-phone-number" in error stack
  • Conditional logic for phone authentication is not properly validating input

Common causes

  1. Phone number input field is empty or null when passed to signInWithPhoneNumber()
  2. Phone number variable is undefined or has not been declared
  3. Form submission handler does not validate phone number before calling authentication method
  4. Phone number string contains only whitespace characters
  5. Conditional logic fails to extract phone number from user input before authentication
  6. Phone number state variable has not been initialized properly in your component

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

1Validate phone number input before authentication

Add a simple check to ensure the phone number is not empty or null before calling the Firebase authentication method:

typescript
const phoneNumber = userInput.trim();

if (!phoneNumber || phoneNumber.length === 0) {
  console.error('Phone number is required');
  setError('Please enter a valid phone number');
  return;
}

try {
  const confirmationResult = await signInWithPhoneNumber(
    auth,
    phoneNumber
  );
} catch (error) {
  console.error('Authentication failed:', error.code);
}

This prevents the auth/missing-phone-number error by validating input before the Firebase call.

2Include country code in phone number format

Firebase requires phone numbers to be formatted with a country code prefix (e.g., +1 for US, +44 for UK). Make sure your input validation includes this:

typescript
const phoneNumber = userInput.trim();

// Ensure phone number starts with +
if (!phoneNumber.startsWith('+')) {
  setError('Phone number must include country code (e.g., +1 for US)');
  return;
}

if (phoneNumber.length < 10) {
  setError('Phone number is too short');
  return;
}

await signInWithPhoneNumber(auth, phoneNumber);
3Enable Phone Number authentication in Firebase Console

Before implementing phone authentication, you must enable it in your Firebase project:

1. Go to the Firebase Console (console.firebase.google.com)
2. Select your project
3. Navigate to Authentication section
4. Click on "Sign-in method" tab
5. Find "Phone Number" in the list
6. Click the toggle to enable it
7. Click "Save"

Without this enabled, all phone authentication attempts will fail. This is a project-level configuration, not code-level.

4Handle the error with proper error checking

Wrap your phone authentication call in try-catch and handle specific error codes:

typescript
try {
  const phoneNumber = form.phoneInput.value.trim();
  
  if (!phoneNumber) {
    throw new Error('Phone number is required');
  }
  
  const confirmationResult = await signInWithPhoneNumber(
    auth,
    phoneNumber
  );
  
  // Store for later use
  window.confirmationResult = confirmationResult;
  
} catch (error: any) {
  switch(error.code) {
    case 'auth/missing-phone-number':
      setError('Please enter your phone number');
      break;
    case 'auth/invalid-phone-number':
      setError('Phone number format is invalid');
      break;
    case 'auth/quota-exceeded':
      setError('Too many requests. Please try again later');
      break;
    default:
      setError(error.message);
  }
}
5Use test phone numbers during development

Firebase allows you to register test phone numbers in the console to test without sending real SMS messages:

1. In Firebase Console, go to Authentication > Sign-in method
2. Expand the "Phone" provider
3. Click on "Phone numbers for testing"
4. Add a test phone number (e.g., +1 650-555-3434) and verification code
5. In your app, when you use a registered test number, entering the test code will authenticate without sending SMS

Example test numbers you can use:
- +1 650-555-3434 (US format)
- +44 7444 555666 (UK format)
- +81 90-1234-5678 (Japan format)

Test numbers prevent quota issues and let you verify your authentication flow works correctly.

Advanced notes

The auth/missing-phone-number error is a validation error that happens before Firebase servers are contacted. It's different from auth/invalid-phone-number, which means the phone number format is wrong (e.g., missing country code, wrong length). The error occurs at the client-side validation stage, so if you're seeing this, your Firebase configuration is correct but your input handling needs fixing.

In web applications, Firebase uses reCAPTCHA as part of phone authentication. Make sure your domain is whitelisted in Firebase Console under Authentication > Settings > Authorized domains. On mobile (iOS/Android), the validation happens through the native Firebase SDK with similar requirements.

If you're building a reusable phone input component, consider creating a utility function that formats and validates phone numbers before passing them to Firebase:

Frequently asked questions

What does "auth/missing-phone-number" mean?
Firebase Authentication throws the auth/missing-phone-number error when you attempt to authenticate a user via phone number but fail to provide a phone number string to the authentication method. This error indicates that the required phone number parameter is either missing, null, undefined, or empty in your authentication function call. Firebase requires a properly formatted phone number (including country code) to initiate phone-based authentication via SMS verification.
How do I fix "auth/missing-phone-number"?
The auth/missing-phone-number error occurs when calling Firebase phone authentication methods without providing a valid phone number. This is thrown when the phone number parameter is missing or not passed to signInWithPhoneNumber or verifyPhoneNumber.
What causes "auth/missing-phone-number"?
Phone number input field is empty or null when passed to signInWithPhoneNumber() Phone number variable is undefined or has not been declared Form submission handler does not validate phone number before calling authentication method
Is the "auth/missing-phone-number" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading