Firebase Error: Unexpected error while deploying database rules

Viewed 1392

I am trying to deploy my angular app to firebase, I have tried all methods to init firebase, select hosting and then deploying my app on firebase from various tutorials. But I always get an error:

Unexpected Error from firebase CLI

I don't know what's wrong .

This is how my firebase-debug.log looks

[debug] [2020-03-26T10:42:00.096Z] ----------------------------------------------------------------------
[debug] [2020-03-26T10:42:00.098Z] Command:       C:\Program Files\nodejs\node.exe C:\Users\pulki\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js deploy
[debug] [2020-03-26T10:42:00.098Z] CLI Version:   7.16.1
[debug] [2020-03-26T10:42:00.098Z] Platform:      win32
[debug] [2020-03-26T10:42:00.098Z] Node Version:  v10.16.3
[debug] [2020-03-26T10:42:00.099Z] Time:          Thu Mar 26 2020 16:12:00 GMT+0530 (India Standard Time)
[debug] [2020-03-26T10:42:00.099Z] ----------------------------------------------------------------------
[debug] [2020-03-26T10:42:00.099Z] 
[debug] [2020-03-26T10:42:00.105Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2020-03-26T10:42:00.105Z] > authorizing via signed-in user
[debug] [2020-03-26T10:42:00.105Z] [iam] checking project frezzo-pul5 for permissions ["firebase.projects.get","firebasedatabase.instances.update","firebasehosting.sites.update"]
[debug] [2020-03-26T10:42:00.108Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2020-03-26T10:42:00.108Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token  
 <request body omitted>
[debug] [2020-03-26T10:42:00.624Z] <<< HTTP RESPONSE 200
[debug] [2020-03-26T10:42:00.630Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/frezzo-pul5:testIamPermissions  

[debug] [2020-03-26T10:42:02.770Z] <<< HTTP RESPONSE 200
[debug] [2020-03-26T10:42:02.772Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/frezzo-pul5  

[debug] [2020-03-26T10:42:03.760Z] <<< HTTP RESPONSE 200
[info] 
[info] === Deploying to 'frezzo-pul5'...
[info] 
[info] i  deploying database, hosting
[info] i  database: checking rules syntax...
[debug] [2020-03-26T10:42:03.764Z] >>> HTTP REQUEST PUT https://frezzo-pul5.firebaseio.com/.settings/rules.json?dryRun=true  
 {
    "rules": {
        ".read": true,
        ".write": true
    }
}
[debug] [2020-03-26T10:42:06.330Z] <<< HTTP RESPONSE 404
[debug] [2020-03-26T10:42:06.330Z] <<< HTTP RESPONSE BODY {
  "error" : "Firebase error. Please ensure that you spelled the name of your Firebase correctly"
}

[error] 
[error] Error: Unexpected error while deploying database rules.

I have set no security on my firebase Database. Is that an issue ?

I have also tried firebase serve to locally check my app and that just works fine.

Thanks for you help !!

2 Answers

If you deactivated one or more of the functions since activation, when running $ firebase init for the first time, it will mess up things when trying to deploy.

For example, sometimes realtime databases get automatically deactivated if you are not using them, just try to re-enable them to be able to deploy. Otherwise, you'll need to re-run the init with different options, and remove unused files for it to work.

Try initiating the firebase database from console. In most cases, the firebase database is not set on the cloud, so the console utility is not able to upload the db rules, and hence gives this error. Try using the following commands:

firebase init database

following updates will follow on the console:

=== Database Setup
i  database: ensuring required API firebasedatabase.googleapis.com is enabled...
⚠  database: missing required API firebasedatabase.googleapis.com. Enabling now...
✔  database: required API firebasedatabase.googleapis.com is enabled

? It seems like you haven’t initialized Realtime Database in your project yet. Do you want to set it up? Yes
? Please choose the location for your default Realtime Database instance: us-central1
✔ Creating your default Realtime Database instance: ********-default-rtdb

With this, your database deployment error might get resolved.

Related