'Firebase hosting deployment error Error: Error: 404, Requested entity was not found
i have hosted a static website on firebase and i am using node.js. when i am trying to deploy my website i am facing this error.
C:\Users\Ankur-PC\Desktop>firebase deploy
=== Deploying to 'wo*****win'...
i deploying hosting
**Error: HTTP Error: 404, Requested entity was not found.**
i was also trying these cmd to resolve this error
npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools
Solution 1:[1]
Unless the source of your website is in C:\Users\Ankur-PC\Desktop , you are executing the command in the wrong directory
try to cd [source dir] and then deploy
Solution 2:[2]
I had to add site
property to firebase.json
to fix this.
{
"hosting": {
"site": "my-app-id",
"public": "app",
...
...
}
Solution 3:[3]
update your Firebase npm package to latest version . It works for me
npm install -g firebase-tools
Solution 4:[4]
You have to make sure that you have a Web app added in your Firebase console.
Then, go to Build -> Hosting and set that up. You'll be prompted to add a name for your site. Copy what you type in the box here...
...and add it to your firebase.json file here:
"hosting": {
"site": "stack-overflow-example", // here
"public": "build/web",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
Solution 5:[5]
If you have a redirect to a Cloud Run or Cloud Function, make sure it's running.
Solution 6:[6]
It happened to me when I initiate the project in CLI, and THEN setup a second hosting in the same project.
The solution is to edit the firebase.json and adding the new hosting you wish to deploy:
{
"hosting": [
{
"target": "web-page", // <-- This is a nickname of a resource (a hosting in firebase)
"public": "public",
....
},
{
"target": "web-app",
"public": "public",
....
},
]
}
Now you have to select the target:
firebase target:apply hosting [name] [resource]
For example, let's say the name is "web-page" as in the .json and the name of the hosting you are targeting is "hosting-web", this last one is literally the name you use in Firebase Console:
firebase target:apply hosting web-page hosting-web
For more reference: https://firebase.google.com/docs/cli/targets
Solution 7:[7]
I faced the same problem when I tried to have main domain and subdomin.
The problem was this message 404, Requested entity was not found
because I tried to deploy my subdomain to the hosting server and the resource_id
entity does not exist in the file of .firebasesrc
I added in the targets
filed the same ID of the firebase hosting project ID and the problem has been solved.
Solution 8:[8]
I tried every above solution but it didn,t work. This is how i solve it.
Delete firebase files and dist folder {firebaserc, firebase.jason, dist}
Now build again and follow all steps
Solution 9:[9]
Had same issue and finally solved it.
1. firebase login 2. firebase use --add (Choose the right Project ID) 3. firebase init (select hosting, than correct Project ID) 4. if needed (npm run build) 5. firebase deploy
Solution was number 2 Choosing the right Project ID Because some how firebase commands was refering automatically to a wrong Project ID
Good Luck
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow