Error when serving npm http-server through terminal. (Error 404)
Asked Answered
O

3

20

I have been trying to run a local http server for my HTML files after figuring out that the problem I was having with ng-view is that chrome does not support cross origin requests due to security reasons. Hence, I downloaded the npm http-server and tried running my html code and I get the error message:

Starting up http-server, serving indexTemplate.html
Available on:
  http://127.0.0.1:8080
  http://172.27.88.21:8080
Hit CTRL-C to stop the server
[Mon Jun 27 2016 19:48:11 GMT+0900 (KST)] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36"
[Mon Jun 27 2016 19:48:11 GMT+0900 (KST)] "GET /" Error (404): "Not found"

Can anyone help me in figuring out what the problem is and how I can solve it? Any suggestions and help would be much appreciated!

Overcoat answered 27/6, 2016 at 11:49 Comment(5)
So did you try to go to http://127.0.0.1:8080/indexTemplate.htmlBlenny
yeah it wouldn't loadOvercoat
Try to run just http-server without indexTemplate.html. I just try to run http-server in a folder where i only have index.html and it works just fineBlenny
Thank you! I didn't know that you just run the http-server in the folder and not the file. Works like a charm now.Overcoat
Same error on HerokuRexrexana
W
16

Try to run just http-server without indexTemplate.html as a parameter, in the folder where you only have indexTemplate.html and it should work just fine.

Weevil answered 27/6, 2016 at 11:49 Comment(0)
T
9

While you are serving Please make sure you are serving an entire folder and not a file. For example : NOT RIGHT

http-server "/home/ubuntu/sandbox/basicserver/index.html"

But RIGHT:

http-server "/home/ubuntu/sandbox/basicserver/"

Teetotaler answered 11/4, 2020 at 9:44 Comment(1)
this is the perfect answerEvitaevitable
A
0

I also had the same issue with an angular app, the problem was I was running the command at the src folder

PS D:\Pub Sub Kafka\App\NotificationApp\angular-pwa-app\src> http-server -p 8080 -c-1 dist/angular-pwa-app

I got the error

This localhost page can’t be found

Then I went one folder up where the dist folder located then ran the command

PS D:\Pub Sub Kafka\App\NotificationApp\angular-pwa-app> http-server -p 8080 -c-1 dist/angular-pwa-app

and it rendered the page on http://localhost:8080/

Aggregation answered 11/1, 2023 at 6:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.