Skip to content

Firestore errorFirestore: “Failed to get document because the client is offline”

The app opens to a blank screen and the console says Failed to get document because the client is offline, even though the device is online. Firestore couldn’t reach the backend before giving up, and had no cached copy to fall back on. Here’s what Firestore does, in Firebase’s words, and what we check, or hand it over at a fixed price.

Short answer

Firestore’s get() tried the server, failed or timed out, and found nothing in the offline cache. Check that the firebaseConfig projectId matches a project with a Firestore database, and that nothing (an ad blocker, proxy or firewall) blocks firestore.googleapis.com. For first-load screens, a realtime listener (onSnapshot) delivers data once the connection arrives, where a one-off get() fails.

Why Firestore thinks it’s offline

  1. 01

    The server didn’t answer and there was no cache

    “On platforms with offline support, the client library will use the offline cache if the network is unavailable or if the request times out.” Firebase, Get data with Cloud Firestore

    A get() falls back to the cache when the network fails or times out. On a first visit, or on the web where the cache is off by default, there is nothing there, so the call fails.

  2. 02

    The config points at the wrong project or no database

    A projectId from another project, a missing environment variable, or a project where the Firestore database was never created, all leave the client with no backend to reach. Check the config the live build actually uses.

  3. 03

    A proxy, VPN or network blocks the connection

    “Configures the SDK's underlying transport (WebChannel) to automatically detect if long-polling should be used.” Firebase, FirestoreSettings

    Firestore’s web SDK keeps a long-lived connection open, which some proxies and corporate networks break. Recent versions detect this and switch to long-polling on their own; an older SDK, or the setting turned off, can leave the app stuck.

  4. 04

    Web apps have no persistent offline cache by default

    “For the web, offline persistence is disabled by default.” Firebase, Access data offline

    On Android and iOS the cache persists by default, so a repeat visit can still show data. On the web, the cache lives only in memory for the session. To keep the last data between visits, initialize Firestore with initializeFirestore(app, { localCache: persistentLocalCache() }).

Checked against the vendor’s docs on : Firebase docs: Get data with Cloud Firestore (source options); Firebase docs: Access data offline; Firebase reference: FirestoreSettings.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

Related: Firebase Missing or insufficient permissions · Firestore quota exceeded · Firebase No Firebase App [DEFAULT] has been created · Firestore query requires an index

Questions

More on this error

Is it a security rules problem?

Not usually. A rules problem returns Missing or insufficient permissions, which means the request reached the server. Offline means it didn’t.

Should I force long-polling?

Only if auto-detection is off or you are on an old SDK and you’ve confirmed the network is the cause. Firebase’s reference says auto-detection has been on by default since v9.22.0 of the JavaScript SDK.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; we reply by email, usually within one business day.