How to fix auth/user-cancelled in Firebase

FirebaseBEGINNERLOWUpdated Dec 22, 2025ยท 244 views

The auth/user-cancelled error occurs when a user dismisses or cancels a Firebase authentication flow, such as closing a sign-in popup or navigation dialog. While this is intentional user behavior, it needs proper error handling to avoid confusing users with unexpected error messages.

Quick fix

Fixes auth/user-cancelled

try {
  const result = await signInWithPopup(auth, googleProvider);
  // Handle successful sign-in
} catch (error) {
  if (error.code === "auth/user-cancelled") {
    // User cancelled the operation - handle gracefully
    console.log("Sign-in cancelled by user");
  } else {
    // Handle other authentication errors
    console.error("Sign-in failed:", error.message);
  }
}
  1. Catch the user-cancelled error in your sign-in handler
  2. Display appropriate messaging for user cancellation
  3. Check for related cancellation error codes
  4. Test on different platforms and browsers
firebase โ€” error
try {
const result = await signInWithPopup(auth, googleProvider);
// Handle successful sign-in
} catch (error) {
if (error.code === "auth/user-cancelled") {
// User cancelled the operation - handle gracefully
console.log("Sign-in cancelled by user");
} else {
// Handle other authentication errors
console.error("Sign-in failed:", error.message);
}
}
auth/user-cancelled

What this error means

The "auth/user-cancelled" error is thrown by Firebase Authentication when a user deliberately cancels an authentication operation before it completes. This commonly happens when: 1. A sign-in popup is dismissed before the user finalizes authentication 2. A redirect-based OAuth flow is closed by the user 3. A phone authentication dialog is canceled during verification 4. A user presses "back" or taps outside a modal authentication interface Unlike other authentication errors that indicate technical problems, this error represents an intentional user action to abandon the sign-in process.

Typical symptoms

  • FirebaseError with code "auth/user-cancelled" appears in the console
  • Promise rejection occurs without the user successfully completing sign-in
  • User is returned to the previous screen unexpectedly
  • Alarmist error messages are displayed when user simply closes a dialog

Common causes

  1. User closes or dismisses a pop-up authentication window before completing sign-in
  2. User navigates away during a redirect-based OAuth flow
  3. User taps "Cancel" or "Back" on an authentication dialog or modal
  4. Browser blocks a pop-up window before it fully loads
  5. Another conflicting authentication popup was opened simultaneously

How to fix "auth/user-cancelled"

1Catch the user-cancelled error in your sign-in handler

Wrap your Firebase authentication calls in a try-catch block to handle the cancellation gracefully:

javascript
try {
  const result = await signInWithPopup(auth, googleProvider);
  // Handle successful sign-in
} catch (error) {
  if (error.code === "auth/user-cancelled") {
    // User cancelled the operation - handle gracefully
    console.log("Sign-in cancelled by user");
  } else {
    // Handle other authentication errors
    console.error("Sign-in failed:", error.message);
  }
}
2Display appropriate messaging for user cancellation

Avoid showing alarming error messages for user cancellation. Instead, provide neutral feedback:

javascript
if (error.code === "auth/user-cancelled") {
  // Optional: Show a subtle message or simply return to login
  setMessage("Sign-in cancelled");
  // Or silently return without showing an error
} else {
  setError(`Sign-in failed: ${error.message}`);
}
3Check for related cancellation error codes

Firebase may throw similar but distinct error codes depending on the platform and method:

- auth/popup-closed-by-user: User closed the popup window
- auth/cancelled-popup-request: Another popup was opened before this one completed
- auth/redirect-cancelled-by-user: OAuth redirect was cancelled

Handle all of these the same way as auth/user-cancelled:

4Test on different platforms and browsers

The user-cancelled error may behave differently across platforms:

- Web (Chrome, Firefox, Safari): Most common with popup-based sign-in
- iOS: May occur after dismissing a modal or pressing back
- Android: Common when user closes a dialog or navigates away

Test your error handling in each target environment to ensure graceful fallback behavior.

Advanced notes

For FirebaseUI implementations, handle cancellation using built-in callbacks. FirebaseUI-Web provides an onSignInCancelled callback, and FirebaseUI-Android exposes AuthException.AuthCancelledException. On iOS with Phone Authentication, ensure you handle cancellation after captcha verification completes.

Note that "auth/user-cancelled" does not appear in official Firebase error documentation, making it easy to miss. Always check the error code attribute (error.code) rather than relying on error messages, as messages may vary by platform and language.

Frequently asked questions

What does "auth/user-cancelled" mean?
The "auth/user-cancelled" error is thrown by Firebase Authentication when a user deliberately cancels an authentication operation before it completes. This commonly happens when: 1. A sign-in popup is dismissed before the user finalizes authentication 2.
How do I fix "auth/user-cancelled"?
The auth/user-cancelled error occurs when a user dismisses or cancels a Firebase authentication flow, such as closing a sign-in popup or navigation dialog. While this is intentional user behavior, it needs proper error handling to avoid confusing users with unexpected error messages.
What causes "auth/user-cancelled"?
User closes or dismisses a pop-up authentication window before completing sign-in User navigates away during a redirect-based OAuth flow User taps "Cancel" or "Back" on an authentication dialog or modal
Is the "auth/user-cancelled" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading