Ionic/Angular + Firebase with emulator on Android device = auth/network-request-failed

I have to improve existing Ionic app using firebase as auth method for users login into app. For purpose don't touch existing list of previously registered users in production firebase app, I have to create new locally using firebase emulator. After adding and setup local auth & DB emulator extensions, I have added this into app.module.ts:

if (window.location.hostname === 'localhost') {

After continue with adding new UI and logical features, using web browser to test my work, I switch to Android platform. After running app and executing

firebase.auth().signInWithEmailAndPassword(email, password);

I got following error:

 "code": "auth/network-request-failed",
 "message": "A network error (such as timeout, interrupted connection or unreachable host) has occurred."

I have spent some time to figure out what is wrong, why all previously worked fine in browser, but not on real device.

1 answer

  • answered 2021-04-21 16:31 CodeBy

    Whereas on Android device

    window.location.hostname === 'localhost

    this will be executed


    so Firebase searching auth service on device on port 9099, that not exists, and produce such error.

    To fix this just run in terminal

    adb reverse tcp:9099 tcp:9099