Not planned
Description
[firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff, this error appears, although there is a network connection, this happens a lot on Android devices, and a few times on iOS.
Does anyone know what can be the problem?
I've found similar reports in issues section, but they don't seem to have any solution.
I'm using "@react-native-firebase/firestore": "^14.2.2"
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
mikehardy commentedon Aug 16, 2022
In my experience, usually Google Compute Platform does not like the client's network endpoint (blocklisted VPN IP address or similar) or the network is down, or API keys are restricted or similar.
Impossible to say without being able to definitely reproduce it with knowledge of the client's network environment, and knowledge of the google computer platform / firebase project / API key configuration
Ggayane commentedon Aug 16, 2022
I've tested on the same network both iOS and Android, iOS works fine, on Android sometimes I see this error, and whenever this happens right after it when I try another request (like
firestore().doc(smoething).get();
) it works as expected, without any errors. And I also check user token while this error appears, token is fine and not expired.mikehardy commentedon Aug 16, 2022
That's odd - I wonder if the android device is somehow putting the network to sleep aggressively, for instance for power-saving.
It appears to be this case from the error message:
Ggayane commentedon Aug 16, 2022
that's possible I guess, the solution can be to catch this error and retying to do the same call again.
AdnanIqbalKhan commentedon Aug 17, 2022
I am getting the same issue
using @react-native-firebase/firestore": "^14.7.0"
mikehardy commentedon Aug 24, 2022
@AdnanIqbalKhan you assert
...but providing no evidence to back up the assertion
Troubleshooting requires precision, accuracy, and details. In the future please do not "metoo" post on other people's details unless you are certain based on concrete evidence you have the same issue.
The original poster has provided some logging indicating it may be that the app is having a transient network connectivity issue.
No one has reported followup information where details about the network environment at the time of the error are provided, so we just have a hypothesis right now and are waiting for details
AdnanIqbalKhan commentedon Aug 24, 2022
@mikehardy I don't know what causes the issue
in a physical device, it works fine
but in the emulator firebase/auth is working but firebase/firestore and firebase/database not responding
This is the error I get.
"[Error: [firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.]"
AdnanIqbalKhan commentedon Aug 29, 2022
The problem is with Android Emulator v 31.3.10 Turning off wifi in the emulator and turning on its data connection works for me. Check these for further details.
Firebase doesn't work on Android Studio Emulator
raulgordejev commentedon Sep 30, 2022
I've had the same problem for years with react-native-firebase. What happens (I think) is that OS battery saver/optimisation settings kill the firestore connection while the app is backgrounded for some time (a few minutes). After opening the app again, firestore takes quite a long time to reconnect - around 30 seconds up to 1 minute. Get queries return the [firestore/unavailable] error, but subscriptions just silently wait until firestore is reconnected.
It's been a really annoying issue to deal with and I haven't seen any proper solutions for that yet. As a workaround I'm currently using firestore REST API to fetch data in addition to subscriptions in the more critical places in the app.
From crashlytics logs it seems to be happening slightly more on iOS, but I've found it to be easier to reproduce on Android. Specifically Androids 10 to 12.
To reproduce this issue:
github-actions commentedon Dec 5, 2022
Hello 👋, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?
Thank you for your contributions.
3 remaining items
ftaibi commentedon Aug 23, 2024
still happening
alikrodrigues commentedon Sep 1, 2024
Still happening it a lot of times, most of the times in android OnePlus8

jd-alexander commentedon Sep 2, 2024
For me the error was taking place due to some WiFi issues. When I switched to another network it disappeared.
Daniel-W1 commentedon Sep 26, 2024
has anyone fixed this issue, it happened to me too, and I couldn't find any fix.
francesco-clementi-92 commentedon Oct 16, 2024
Hello, I'm experiencing the same error. Is there a way to check if the connection has been restored or not?
mikehardy commentedon Oct 16, 2024
perhaps
https://reactnative.dev/docs/appstate#addeventlistener
listen for transition to foreground, do a test get to firestore and if it is unavailble try a pair of calls to toggle the network down then up
https://rnfirebase.io/reference/firestore#disableNetwork / https://rnfirebase.io/reference/firestore#enableNetwork
I have not tried this but something like this might work
If there is no way to force the network to reinit and you must wait, then in the app could also maintain a global "firestore network is available" status flag somewhere, and in the AppState listener on transition to foreground you could try a firestore doc get and update the availability flag based on the result, testing it in a loop until it is available. Use the availability flag in other areas to do what makes sense for your app's use cases...
amarinsam commentedon Nov 22, 2024
For me, I had named my Firestore database to something other than (default). Deleting the database, and creating a new one named (default) fixed the error.
sarnakov commentedon Dec 22, 2024
At first I thought it was a joke, but apparently it's a solution...
Sneidon commentedon Jan 6, 2025
This fixed the issue for me.
ErangaD commentedon Apr 12, 2025
this works lol
hungtooc commentedon Apr 13, 2025
Fixed for me!
dogankablan commentedon Apr 25, 2025
It's really weird, but it worked.Firebase definitely needs to find a proper solution for this.
jerryphm commentedon Apr 27, 2025
I encountered the same issue when reading from firestore, both in a Cloud Function and in mobile app. Specifying the database name when calling
getFirestore
fixed the error for me:ngothanhtai commentedon May 19, 2025
for my case, I haven't clicked Create database in Firebase console.
TheRealMikeD commentedon May 28, 2025
FWIW, I see this error from time to time on my iPhone 13, which I use as my main dev/testing device. I also have NordVPN running on that phone, which might be contributing to the issue, although that's not 100% verified. I just notice that I don't ever get the error, and data loads more quickly, if I have the VPN turned off.
I also use Sentry in my app, and I do occasionally get Sentry reports of this error in the wild. In those cases, I can't really tell if the users have a VPN on their phones or not.
My solution has been twofold: