Firebase Realtime Database connection killed: Different Region

Viewed 12942

I am trying to build a simple login user authentication Android application that uses Firebases Realtime Database but I am getting the error:

[Firebase Database connection was forcefully killed by the server. Will not attempt to reconnect. Reason: The database lives in a different region. Please change your database URL to https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app]

I am currently using the Singapore(asia-southeast1) server since I live in the Philippines. Is this wrong? or Should I be using the US one? How do I change my Database URL?

4 Answers

It looks like the google-services.json file that you use doesn't contain the Realtime Database URL, probably because you downloaded it before the database was created. In such cases the SDK assumes that the database is in the US (the original region), and you get an error that there's a mismatch.

There are two possible solutions:

  1. Download an updated google-services.json from the Firebase console, and add that to your Android app.
  2. Specify the database URL in your code instead, like this: FirebaseDatabase.getInstance("https://vax-in-60807-default-rtdb.asia-southeast1.firebasedatabase.app")...

Both have the same result, so pick whichever one seems easiest to you.

It cat still not work after the accepted answer (as in my case). If so, try:

  • Clean Project
  • Rebuild Project
  • Invalidate Caches & Restarte

and run it again.

If you are a New Flutter User who followed the new firebase doc, run this command in the terminal. It will automatically update the firebase_options.dart file.

flutterfire configure

I faced the same problem and that's because when you set up the app, the google-service.json doesn't contain the firebase_url.

These problems faced you when configuring your set up manually, You can fix all that problems by using flutterfire, it will help you a lot and set up your app in a few steps. see docs firebase

Related