How to fix unavailable in Firebase

FirebaseINTERMEDIATEHIGHUpdated Dec 22, 2025ยท 263 views

The Firebase "unavailable" error occurs when your application cannot reach the Firebase service backend. This is typically a transient network or service issue that can be resolved with proper error handling, retry logic, and connection verification.

Quick fix

Fixes unavailable

if (navigator.onLine) {
  console.log("Device is online");
} else {
  console.log("Device is offline");
}
  1. Check Firebase Service Status
  2. Verify Network Connectivity
  3. Ensure Firebase is Fully Initialized Before Use
  4. Implement Exponential Backoff Retry Logic
firebase โ€” error
if (navigator.onLine) {
console.log("Device is online");
} else {
console.log("Device is offline");
}
unavailable

What this error means

This error indicates that the Firebase service is currently unreachable from your application. The error commonly appears across multiple Firebase services including Cloud Firestore, Realtime Database, Cloud Functions, and Cloud Messaging. When this error occurs, the Firebase SDK cannot establish or maintain a connection to the backend, preventing operations from completing. The error message typically states "The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff." Unlike permission or validation errors, an unavailable error is usually temporary and caused by network connectivity issues, Firebase service interruptions, or device offline status. The SDK will often retry automatically, but implementing your own retry logic with exponential backoff provides better control and user experience.

Typical symptoms

  • Operations fail with "[firebase/unavailable]" or similar error code
  • Read and write requests timeout after 10+ seconds
  • Firebase console works but your app cannot connect to the service
  • Error occurs intermittently and resolves after retrying
  • The app works on some networks but fails on others (WiFi vs cellular)
  • Error appears primarily on Android devices but occasionally on iOS or web
  • First app installation fails but subsequent launches succeed

Common causes

  1. Temporary Firebase service outage or degraded performance in your region
  2. Poor network connectivity or unstable internet connection on client device
  3. Device is offline or has no network access
  4. Firewall, VPN, or corporate proxy blocking Firebase endpoints (*.firebase.io, *.firebaseio.com)
  5. Firebase service initialization not complete before making API calls
  6. SDK version mismatch or outdated Firebase client library
  7. Too many concurrent connections exceeding Firebase quotas
  8. Regional latency causing requests to timeout before completion

How to fix "unavailable"

1Check Firebase Service Status

Before troubleshooting your code, verify that Firebase services are operational.

Visit the Firebase Status Dashboard at https://status.firebase.google.com/ to check for ongoing incidents or maintenance affecting Firebase services. If there is a service outage affecting your region or service type, wait for Firebase to restore serviceโ€”there is nothing you can do on your client until the backend recovers.

2Verify Network Connectivity

Ensure your device has a working internet connection.

Test your connection:

javascript
if (navigator.onLine) {
  console.log("Device is online");
} else {
  console.log("Device is offline");
}

If offline, connect to a working network. If still failing after connecting:
- Try switching from WiFi to cellular or to a different network
- Disable VPN or corporate proxy temporarily to test
- Check if your firewall blocks Firebase endpoints (*.firebase.io, *.firebaseio.com)
- Test on a different device or network to isolate the issue

3Ensure Firebase is Fully Initialized Before Use

The unavailable error often occurs when you call Firebase APIs before the SDK finishes initializing.

javascript
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";

const firebaseConfig = {
  apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
  authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
  projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
  storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
  messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
  appId: process.env.REACT_APP_FIREBASE_APP_ID,
};

const app = initializeApp(firebaseConfig);
const db = getFirestore(app); // Ensure initialization succeeds before using db

// Wait for initialization before querying
await db.ready(); // Some SDKs support this pattern

Make sure all environment variables are set correctly and the app initializes without errors.

4Implement Exponential Backoff Retry Logic

Firebase recommends handling transient unavailability with automatic retry logic using exponential backoff.

javascript
async function queryWithRetry(queryFn, maxRetries = 3) {
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
    try {
      return await queryFn();
    } catch (error) {
      if (error.code === "unavailable" && attempt < maxRetries) {
        const delayMs = Math.min(1000 * Math.pow(2, attempt - 1), 10000); // 1s, 2s, 4s max 10s
        console.log(`Retry attempt ${attempt} in ${delayMs}ms...`);
        await new Promise(r => setTimeout(r, delayMs));
      } else {
        throw error; // Rethrow after max retries or non-transient error
      }
    }
  }
}

// Usage
const result = await queryWithRetry(async () => {
  const snapshot = await getDocs(collection(db, "users"));
  return snapshot.docs;
});

This approach gives transient issues time to resolve without overwhelming the Firebase backend.

5Check and Update SDK Versions

Outdated Firebase SDKs may have connectivity bugs or compatibility issues.

For npm/Node.js:

bash
npm install firebase@latest

For React Native:

bash
npm install @react-native-firebase/firestore@latest

For Flutter:

bash
flutter pub upgrade cloud_firestore

For Android (native):
Update your build.gradle:

gradle
dependencies {
  implementation "com.google.firebase:firebase-firestore:35.0.0" // Update to latest
}

After upgrading, clear your build cache and restart/rebuild your app.

6Enable Network for Firestore Offline Mode

If your Firestore SDK entered offline mode and never reconnected, explicitly re-enable networking.

javascript
import { enableNetwork } from "firebase/firestore";

const db = getFirestore();

// Force reconnection
await enableNetwork(db);
console.log("Network re-enabled");

For Realtime Database, disconnect and reconnect:

javascript
import { ref, goOffline, goOnline } from "firebase/database";

const db = getDatabase();
goOffline(db);

// Wait a moment, then reconnect
setTimeout(() => {
  goOnline(db);
  console.log("Database reconnected");
}, 1000);
7Check Authentication Status

Some Firebase services require authentication. If your auth token expired, the service becomes unavailable.

javascript
import { getAuth, onAuthStateChanged } from "firebase/auth";

const auth = getAuth();

onAuthStateChanged(auth, (user) => {
  if (user) {
    console.log("User authenticated:", user.uid);
    // Now safe to use Firestore/other services
  } else {
    console.log("User not authenticated - Firebase services may be unavailable");
    // Sign in or use anonymous auth
  }
});

// For anonymous auth:
import { signInAnonymously } from "firebase/auth";
await signInAnonymously(auth);

Ensure your user is properly authenticated before making requests to protected services.

8Monitor Connection Status and Implement Graceful Degradation

Add connection monitoring to detect when Firebase becomes unavailable and gracefully degrade your app.

javascript
import { ref, onValue } from "firebase/database";

const db = getDatabase();
const connectedRef = ref(db, ".info/connected");

onValue(connectedRef, (snapshot) => {
  if (snapshot.val() === true) {
    console.log("Firebase connected");
    // Sync data, update UI
  } else {
    console.log("Firebase unavailable - using cached data");
    // Display cached data, disable writes, show offline indicator
  }
});

For Firestore:

javascript
import { enableNetwork, disableNetwork } from "firebase/firestore";

window.addEventListener("online", async () => {
  await enableNetwork(db);
  console.log("Back online - Firestore re-enabled");
});

window.addEventListener("offline", async () => {
  await disableNetwork(db);
  console.log("Offline - Firestore disabled");
});

Advanced notes

Android-Specific Issues: The unavailable error is significantly more frequent on Android than web or iOS. Ensure your device has sufficient memory and network bandwidth. Consider implementing more aggressive retry logic (4-5 attempts) and longer timeouts (15-20 seconds) for Android specifically.

Emulator Issues: When using the Firebase Emulator Suite or Android Emulator, the unavailable error can occur if the emulator cannot reach your development machine's localhost. Ensure localhost:8080 (Firestore emulator) and other emulator ports are accessible from the emulator network.

Regional Deployments: Users in Europe and Asia have reported occasional unavailability with regional databases. If experiencing chronic issues, try selecting US-central1 or checking your Firebase Console for regional availability status.

Rate Limiting: High-frequency requests may trigger rate limiting, causing unavailable errors. Implement request batching and cache-aside patterns to reduce unnecessary queries.

SDK Initialization Race Conditions: Some frameworks (React Native, Flutter) initialize Firebase asynchronously. Ensure you await initialization before making any API calls. Use promise-based patterns rather than synchronous access.

Frequently asked questions

What does "unavailable" mean?
This error indicates that the Firebase service is currently unreachable from your application. The error commonly appears across multiple Firebase services including Cloud Firestore, Realtime Database, Cloud Functions, and Cloud Messaging. When this error occurs, the Firebase SDK cannot establish or maintain a connection to the backend, preventing operations from completing.
How do I fix "unavailable"?
The Firebase "unavailable" error occurs when your application cannot reach the Firebase service backend. This is typically a transient network or service issue that can be resolved with proper error handling, retry logic, and connection verification.
What causes "unavailable"?
Temporary Firebase service outage or degraded performance in your region Poor network connectivity or unstable internet connection on client device Device is offline or has no network access
Is the "unavailable" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading