13

I am trying to get my localhost server on Firebase to work but I am continuing to get the following message in the browser 'Cannot GET /'. I took a look in the console and all it says is 'http://localhost:5000/ 404 (Not Found)'.

I have tried re-running the server using 'firebase serve' and that doesn't help. I ran 'firebase init' again and that didn't help either. I re-installed the firebase tools by running 'npm install -g firebase-tools' and then running firebase serve again and still nothing.

Not sure whats going on because it was initially working. I installed some grunt plugins and moved my index.html file under an html folder although I still have an index.html file under the public folder it still says 'Cannot GET /'

I have also tried in different browsers restarting them etc.

I am using a Mac OS X El Capitan.

Let me know if you need any more info. Thanks in advance

7 Answers 7

7

I had this issue running firebase serve from within the scripts directory in the "Friendly Chat" tutorial. Starting the server from the parent directory got it working again as expected.

Sign up to request clarification or add additional context in comments.

2 Comments

Perfect. Worked for me.
Close the server (firebase console - Ctrl + C) and see that you are in the project (parent) directory. Then try again
2

if this will help someone save time.. a possibility: it could be that the build step did not complete, this was my case, and the build/... directory had no index.html

Comments

2

I had the same issue when was trying to serve an Angular application with the firebase command. Firstly, you should see the firebase.json file. It should contain the "public" value, like:

{
    "public":"dist/ProjectName"
    ...
}

But the dist folder will be auto created only after you build the Angular project:

ng build --prod

After you can do the:

firebase serve

Hope it will be helpful for beginners.

1 Comment

Thank you, i had a typo on the physical folder name, not on the firebase.json file.
1

Ok so got this working but pretty much had to start from scratch again. I deleted the public folder and just moved my html, css, js, and node-module folders out of my project directory and then re-installed firebase-tools and ran the 'firebase init' command and then restarted the localhost server and everything started working again. After which point I moved back all my previous folders and things are working as before.

Not a 100% sure how the issue happened but at one point I did delete my index.html file and then put it back in later on as I was testing something. At which point I feel the issue started. I will try to test this scenario in a test project but I guess for the time being don't delete your index.html file just modify the existing one. Thanks all.

3 Comments

Solution tested and approved !
Did you ever find out more about the issue and I'm not getting the same result. Killed my entire project.
Restarting the project is not an effective solution.
1

The error message shows up if you run 'firebase serve' within the project folder.

Navigate to the parent folder (up one level) using 'cd ..' and start the server from there.

1 Comment

Can you elaborate on what you mean by the project folder? Did you mean if you run it in the functions folder? Because running firebase serve in the project folder (i.e. root) is usually the correct method.
0

Please check if content of your website is present in folder

  "hosting": {
    "public": "<folder with your website files>",

from your config "firebase.json"

Comments

0

If you like me, before overthinking the problem, make sure you provided the correct URL to index.html.

In my case, I didn't take into account different structure of my directory. You should provide the path to index.html relative to the root directory of your firebase project. For example, in my case, the correct URL was http://localhost:5000/button-component/public/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.