Flutter Firebase Auth "[firebase_auth/network-request-failed]": 4-Step Fix for Emulator and Device
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.
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.
- 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. - Match the host to the device. The Firebase docs say the default emulator host is
127.0.0.1and that an Android emulator needs10.0.2.2. A physical device needs your computer's address on the local network instead. - 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 infirebase.json, connect with your computer's local IP, keep both on the same network, and allow the port through your firewall. - 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 runs | Host to pass to useAuthEmulator | Source |
|---|---|---|
| Android emulator | 10.0.2.2, port 9099 | Firebase: "If you are using an Android emulator, you need to use 10.0.2.2" |
| iOS simulator | 127.0.0.1, port 9099 | Firebase's Swift example |
| Flutter web | 127.0.0.1 (web example uses http://127.0.0.1:9099) | Firebase's web example |
| Physical phone | Your computer's local IP, with "host": "0.0.0.0" for the emulator | Firebase 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.
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.
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.
- Test the device. Open any HTTPS page in the phone's browser on the same connection. A captive Wi-Fi portal, a VPN or airplane mode all produce this error.
- Test the build type. If the error appears only in release builds, the problem is in the release configuration. Our guide to a Flutter app that works in debug but not in release covers the missing network permission and cleartext rules.
- Handle it in code. FlutterFire exposes the code on
FirebaseAuthException, so you can show a retry message fornetwork-request-failedand keep other codes, such as the ones in our invalid-credential fix, on their own paths.
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
- Firebase: connect your app to the Authentication emulator, default host and 10.0.2.2 (checked 2026-12-02)
- Firebase: Hosting emulator, testing from other local devices with host 0.0.0.0 (checked 2026-12-02)
- Firebase CLI: firebase.json schema, host and port for each emulator (checked 2026-12-02)
- FlutterFire API: FirebaseAuth.useAuthEmulator (checked 2026-12-02)
- Firebase JS reference: AuthErrorCodes, auth/network-request-failed (checked 2026-12-02)
- Android: network security configuration, cleartext traffic default from API level 28 (checked 2026-12-02)
- FlutterFire issue 7966: network-request-failed fixed by removing the emulator lines (checked 2026-12-02)
- Stack Overflow: the same error on a physical device with the emulator on a laptop (checked 2026-12-02)