Skip to content

Can't access RTDB hosted in the European servers #514

@luispinho

Description

@luispinho

Environment

  • Operating System version: Raspbian 10 (buster) on Raspberry Pi 4
  • Firebase SDK version: firebase-admin 4.4.0
  • Library version: _____
  • Firebase Product: Realtime Database

The problem

Can't start a Python script referencing an empty RTDB URL that's hosted in the West Europe servers as it gives a ValueError: Invalid database URL: error.

I suspect it's because the format of the URL for these databases (which is https://PROJECT_NAME.europe-west1.firebasedatabase.app) is different than the regular firebaseio.com URLs for the databases hosted in the US.

Facing this error, I decided to create a new project and instead of creating and setting the RTDB to be hosted in the European servers, I set it to be hosted in the US ones. After that (in my Python script) I updated my credentials file with the new ones generated in the new Firebase project and replaced the previous URL with the new one ending in firebaseio.com. After doing these changes, I was able to access the database successfully.

Code used:

This is the code in script that causes the error (which is the init app code):

firebase_admin.initialize_app(cred, {
    'databaseURL': 'https://PROJECT_NAME.firebasedatabase.app/'
})

Relevant Code (error output, without code referencing my machine)

  File "/usr/local/lib/python3.7/dist-packages/firebase_admin/db.py", line 69, in reference
    service = _utils.get_app_service(app, _DB_ATTRIBUTE, _DatabaseService)
  File "/usr/local/lib/python3.7/dist-packages/firebase_admin/_utils.py", line 101, in get_app_service
    return app._get_service(name, initializer) # pylint: disable=protected-access
  File "/usr/local/lib/python3.7/dist-packages/firebase_admin/__init__.py", line 295, in _get_service
    self._services[name] = initializer(self)
  File "/usr/local/lib/python3.7/dist-packages/firebase_admin/db.py", line 771, in __init__
    _DatabaseService._parse_db_url(db_url)  # Just for validation.
  File "/usr/local/lib/python3.7/dist-packages/firebase_admin/db.py", line 837, in _parse_db_url
    return cls._parse_emulator_url(parsed_url)
  File "/usr/local/lib/python3.7/dist-packages/firebase_admin/db.py", line 865, in _parse_emulator_url
    'Firebase Realtime Database instance.'.format(parsed_url.geturl()))

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions