12

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
sinake
  • 149
  • 1
  • 1
  • 7

7 Answers7

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.

Max Terry
  • 71
  • 1
  • 4
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

verNsíon1
  • 53
  • 7
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.

Taras Vovkovych
  • 4,062
  • 2
  • 16
  • 21
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.

sinake
  • 149
  • 1
  • 1
  • 7
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.

user7503162
  • 21
  • 1
  • 3
  • 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. – Dirk R May 26 '23 at 14:57
0

Please check if content of your website is present in folder

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

from your config "firebase.json"

Vlad
  • 3,465
  • 1
  • 31
  • 24
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/

iamkirill
  • 310
  • 1
  • 6
  • 12