Flutter Firebase Auth "[firebase_auth/network-request-failed]": 4-Step Fix for Emulator and Device

By · Published 2026-12-02 · Last verified 2026-12-02

What does "[firebase_auth/network-request-failed] A network error has occurred" mean in Flutter?

It means Firebase Authentication could not complete the request over the network: the call timed out, the connection dropped, or the host it tried to reach was unreachable. The message FlutterFire shows reads "A network error (such as timeout, interrupted connection or unreachable host) has occurred." In a Flutter app the most common real cause during development is not a dead internet connection but an app pointed at an Auth emulator the device cannot reach, for example localhost on an Android emulator, or a laptop emulator that only listens on localhost while you test on a physical phone. In production, start with the device's connection. This guide gives a 4-step check that covers both, and was checked against the Firebase documentation and the firebase_auth API docs on 2026-12-02.

Grid of the 4-step Network Request Check: find out whether the app calls the emulator or production, match the host to the device, make the emulator reachable with host 0.0.0.0 and the local IP, and allow plain HTTP, noting the Auth emulator uses port 9099
The 4-step Network Request Check.

The Network Request Check: 4 steps

Short answer: confirm whether the app talks to production or an emulator, match the host to the device type, make the emulator reachable, then rule out blocked plain-HTTP traffic.

  1. Find out which backend you are calling. Search the code for useAuthEmulator. If it runs, every Auth call goes to the emulator, not to Firebase. Comment it out and retry: in FlutterFire issue 7966 the reporter fixed the same error by removing the emulator lines.
  2. Match the host to the device. The Firebase docs say the default emulator host is 127.0.0.1 and that an Android emulator needs 10.0.2.2. A physical device needs your computer's address on the local network instead.
  3. Make the emulator reachable. By default the emulators answer only requests from localhost. To test from another device, set "host": "0.0.0.0" for the Auth emulator in firebase.json, connect with your computer's local IP, keep both on the same network, and allow the port through your firewall.
  4. Check plain HTTP is allowed. The emulator speaks plain HTTP. Android's documentation says cleartext traffic is disabled by default from Android 9 (API level 28), so a request to an http:// host can be blocked until your app opts in for that host.

Which emulator host should the app use?

Short answer: 10.0.2.2 on the Android emulator, 127.0.0.1 on the iOS simulator and the web, and your computer's local IP on a physical device (checked 2026-12-02).

Where the app runsHost to pass to useAuthEmulatorSource
Android emulator10.0.2.2, port 9099Firebase: "If you are using an Android emulator, you need to use 10.0.2.2"
iOS simulator127.0.0.1, port 9099Firebase's Swift example
Flutter web127.0.0.1 (web example uses http://127.0.0.1:9099)Firebase's web example
Physical phoneYour computer's local IP, with "host": "0.0.0.0" for the emulatorFirebase Hosting emulator page on testing from other local devices

Last checked: 2026-12-02. The Dart signature in the firebase_auth 7.1.0 docs is useAuthEmulator(String host, int port, {bool automaticHostMapping = true}). The docs say to call it immediately, before any other Auth method, and not to use it with production credentials because emulator traffic is not encrypted. If the order of calls is the problem, our guide to "No Firebase App [DEFAULT] has been created" covers initialization.

Four-step flow of which Auth emulator host to use: 10.0.2.2 on the Android emulator, 127.0.0.1 on the iOS simulator and Flutter web, and the laptop's local IP on a physical phone
Which emulator host for which device.

How do you switch between emulator and production without editing code?

Short answer: read the emulator flag and host from --dart-define values, so the same build works on an emulator, a phone and production.

// main.dart
const useAuthEmulator =
    bool.fromEnvironment('USE_AUTH_EMULATOR');
const authEmulatorHost =
    String.fromEnvironment('AUTH_EMULATOR_HOST', defaultValue: '10.0.2.2');

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
  if (useAuthEmulator) {
    await FirebaseAuth.instance.useAuthEmulator(authEmulatorHost, 9099);
  }
  runApp(const MyApp());
}

Run it against a physical phone with the laptop's address, and leave the flags off for production:

# emulator running on your laptop, phone on the same Wi-Fi
flutter run --dart-define=USE_AUTH_EMULATOR=true --dart-define=AUTH_EMULATOR_HOST=192.168.1.20

# production: no flags, no emulator
flutter run
// firebase.json (only the emulators block)
{
  "emulators": {
    "auth": { "host": "0.0.0.0", "port": 9099 }
  }
}

Replace 192.168.1.20 with your own computer's address. The host key is part of the emulator settings in the Firebase CLI's published firebase.json schema for the Auth emulator, next to port. Binding to 0.0.0.0 makes the emulator reachable by every device on that network, so use it on a network you trust and turn it off afterwards.

Two columns comparing an emulator run with dart-define flags, an emulator host and firebase.json host 0.0.0.0 against a production run with no flags and no emulator call
One build, two backends.

What if it fails against production, with no emulator?

Short answer: then the request really did not reach Firebase, so test the device's connection, then rule out a build that lacks network permission.

The JavaScript reference lists the same code as auth/network-request-failed, and the Flutter plugin adds its own firebase_auth/ prefix in the printed message. A related message in Firestore, "client is offline," has its own causes; see the Firestore client-is-offline fix.

Is a network error the same as a wrong password?

Short answer: no, because a network error means the request never completed, while credential errors mean Firebase answered and said no.

That difference decides your handling. A wrong-password or invalid-credential error needs a message for the user. A network error needs a retry path and, during development, a look at the steps above. GSPTeck is giosaia's indie studio building mobile and web apps with Flutter and Firebase; see the GSPTeck homepage for the apps.

FAQ

Why does firebase_auth/network-request-failed only happen on my physical phone?

Usually because the app points at an emulator on your laptop that listens only on localhost. Set the Auth emulator host to 0.0.0.0 in firebase.json, pass your computer's local IP to useAuthEmulator, and keep both devices on one network.

What host do I use for the Auth emulator on an Android emulator?

10.0.2.2 with port 9099. Firebase's documentation says the default host is 127.0.0.1 and that an Android emulator needs 10.0.2.2 instead.

Does useAuthEmulator need to be called before sign-in?

Yes. The firebase_auth docs say it must be called immediately, before any Auth methods are accessed. Call it right after Firebase.initializeApp.

Is it safe to leave the emulator host on 0.0.0.0?

Not as a habit. It lets every device on the network reach the emulator, and the docs note emulator traffic is not encrypted. Use it for testing on a network you trust, then switch it back.

Sources

Vertical Pinterest graphic with five points on fixing firebase_auth network-request-failed in Flutter
Pinterest pin: network-request-failed in Flutter.