StackSays
Menu

Authentication · troubleshooter

Firebase Auth domain not working? (auth/unauthorized-domain)

Direct answer

Most often your app's domain isn't in Firebase's Authorized Domains — by default only localhost and your *.firebaseapp.com / *.web.app hosting domain are allowed, which is why sign-in works locally but breaks in production. Add your domain in Authentication → Settings → Authorized domains, then retry. Work the checks below in order.

Symptom

  • ·Error code auth/unauthorized-domain in the console
  • ·OAuth popup/redirect closes or fails
  • ·Sign-in works on localhost but not on the deployed URL

Most likely causes — check in this order

  • ·The deployed domain is not in Authorized Domains — add it in Firebase Console → Authentication → Settings → Authorized domains (the documented #1 cause).
  • ·authDomain in your firebaseConfig doesn't match the project's auth domain.
  • ·For federated providers (Google/GitHub), the OAuth redirect URI isn't registered in that provider's console.

How to verify each

  • ·Reproduce on the exact deployed URL (not a preview alias)
  • ·Read the error code in the browser console — auth/unauthorized-domain points straight at the domain list
  • ·Compare the domain string exactly: host only, no protocol or port

When to stop

If the domain is authorized, authDomain matches, and provider redirect URIs are set but it still fails, capture the full console error and open a Firebase support thread — beyond this, the cause is environment-specific.

These are the officially-documented causes in likely order — not a confirmation of your specific setup. Verify in your Firebase console.

FAQ

Why does Firebase Auth work on localhost but not production?

localhost and your Firebase Hosting domain are authorized by default; every other domain must be added manually in Authentication → Settings → Authorized domains.

Official sources

Next decision