Flutter Firestore "Failed to Get Document Because the Client Is Offline": 4-Step Fix

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

What does "Failed to get document because the client is offline" mean in Flutter?

It means a single-document get() in cloud_firestore couldn't reach the Firestore backend and found no copy of that document in the local cache, so it threw instead of guessing. Firebase's offline guide states the rule plainly: when you're offline, "an empty result is returned" for a query with no cached documents, but "when fetching a specific document, an error is returned instead." In Flutter the exception usually reads [cloud_firestore/unavailable] Failed to get document because the client is offline. The cause isn't always a dead connection: a wrong emulator host, a web app without persistence or a Source.server read can produce the same message on a working network. This guide was checked against the Firebase docs and the FlutterFire API reference on 2026-12-01.

Grid of the 4-step Offline Read Check: find the document get that failed, check the app reaches the right Firestore host, check the cache setting for the platform, pick the read source on purpose, noting web persistence is off by default and the Android emulator uses 10.0.2.2
The 4-step Offline Read Check.

The Offline Read Check: 4 steps

Short answer: find out which read failed, check whether the device can really reach Firestore, check the cache settings for your platform, then choose the right read source for that screen.

  1. Find the read. The error only comes from DocumentReference.get(). A query get() returns an empty snapshot instead, and a snapshots() listener doesn't throw just because the device is offline. Log the document path so you know which screen triggers it.
  2. Check the connection to Firestore, not just the internet. Confirm the app talks to the right project and host: emulator settings left in a release build, an Android emulator pointed at localhost, or a network that blocks Firestore's transport all look like "offline" to the SDK.
  3. Check the cache for your platform. On Android and iOS, offline persistence is on by default. On the web it's off by default, so a first read without a network has nothing to fall back on.
  4. Pick the read source on purpose. Use the default source for normal screens, Source.cache for an instant offline view, and Source.server only where stale data would be wrong, and catch the error there.

Which read throws, and which doesn't?

Short answer: a single-document get throws when nothing is cached, a server-only read throws whenever the backend is unreachable, and queries return empty instead (checked 2026-12-01).

CallOffline, item cachedOffline, nothing cached
doc.get() (default source)Returns the cached copyThrows "client is offline"
doc.get(GetOptions(source: Source.cache))Returns the cached copy at onceThrows a FirebaseException
doc.get(GetOptions(source: Source.server))Throws: the cache is skippedThrows
query.get()Returns cached matchesReturns an empty snapshot, no error
doc.snapshots()Emits the cached copyNo exception; check metadata.isFromCache before trusting what it shows

Last checked: 2026-12-01, against the FlutterFire Source enum, which says server causes "an error if the server cannot be reached" and cache throws on a document get when "there is no data in the cache."

The empty query result is the trap behind a second bug: a list screen that shows "no items" offline looks like data loss. Read snapshot.metadata.isFromCache before telling users their list is empty.

Four-step flow of what each Firestore read does offline: a document get throws when nothing is cached, a server-only read always throws offline, a cache read returns at once, and a query returns an empty result
Which Firestore reads throw offline.

Why does it happen with the Firestore emulator?

Short answer: the app is pointed at a host it can't reach, usually localhost from an Android emulator, so every read looks offline.

Firebase's emulator guide says the default host is 127.0.0.1, but "if you are using an Android emulator, you need to use 10.0.2.2," the special address for the host machine. In Flutter that's one line before any other Firestore call:

// Android emulator: 10.0.2.2 reaches the computer running the emulator suite
FirebaseFirestore.instance.useFirestoreEmulator('10.0.2.2', 8080);

Two more emulator checks. The same guide notes the emulator "clears database contents when shut down" while the SDK's offline cache isn't cleared automatically, so stale cached documents can hide a real problem; it suggests disabling local persistence while you test against the emulator. And make sure the emulator call sits behind a debug-only flag, so a release build never tries to reach your laptop. Our list of reasons a Flutter app works in debug but not in release covers that kind of build-only setting.

Why does it happen on Flutter web?

Short answer: persistence is off by default on the web, and some networks block the streaming transport Firestore uses, so the SDK reports offline even though other requests work.

Two columns comparing emulator causes, such as localhost instead of 10.0.2.2 and stale cache, with web causes, such as persistence off by default and blocked transport fixed with long polling
Emulator causes versus web causes.

How should the app handle it?

Short answer: catch the exception on that one read, show cached or placeholder content, and listen instead of polling where the screen needs live data. The same emulator-host mistakes also break Firebase Auth, which fails with a different error; see how to fix firebase_auth/network-request-failed against the Auth emulator.

try {
  final snap = await ref.get();
  render(snap.data());
} on FirebaseException catch (e) {
  if (e.code == 'unavailable') {
    showOfflineBanner(); // keep the last data on screen
  } else {
    rethrow;
  }
}

Cache settings also change your read bill and query speed. If offline reads feel slow or your read count jumps, compare with why Firestore reads are too high in a Flutter app. GSPTeck is giosaia's indie studio building mobile and web apps with Flutter and Firebase; see the apps on the GSPTeck homepage.

FAQ

Does "client is offline" mean my Firestore data is gone?

No. It means the SDK couldn't reach the backend and didn't have that document cached, so it refused to guess. The document on the server is untouched; read it again once the connection to Firestore works.

Why does a query return empty offline instead of an error?

Firebase designed it that way: offline, a query with no cached documents returns an empty result, while a single-document get returns an error. Check snapshot.metadata.isFromCache before showing an empty state to the user.

Should I turn persistence off to fix the error?

Usually not. On Android and iOS, persistence is what lets a document get succeed offline. Turn it off only when testing against the emulator, where stale cached documents can mislead you.

Is Source.server a fix for stale data?

Only for reads that must be fresh. A server read skips the cache, so it throws whenever the backend can't be reached; wrap it in a try/catch and keep a fallback.

Sources

Vertical Pinterest graphic with five points on fixing the Firestore client is offline error in Flutter
Pinterest pin: Firestore client is offline in Flutter.