GET http://localhost:4200/ 404 (Not Found) after NG Serve

Viewed 23463

I have no idea what is happening here. It has worked for weeks without an issue and the application still works on my laptop, but as soon as I pull new changes to my desktop and try to run my app I get this 404 error. I have tried recloning the repo, reinstalling angular/cli, clear cache, reinstalling node modules folder nothing works.

"GET http://localhost:4200/ 404 (Not Found)" and on the page itself it just says Cannot GET /.

Everything compiles no problem so it must be something to do with the angular/cli server. I am completely stumped can't move on until I find a fix. Have not been able to find this same issue anywhere.

Like I said, it works fine on my laptop. I can make changes to the files on my desktop, compile succesfully, push the the changes, pull them onto my laptop, and see them work there.

Any ideas?

--EDIT--

Just tried making a new test project and it serves just fine.

4 Answers

Please try to run the command as ng serve --open instead of ng serve in the git bash. That worked for me!

After returning to a project after weeks, I was facing the same problem: The server at localhost:4200 responded with "Failed to load resource: the server responded with a status of 404 (Not Found)". After a while I realized that I had previously changed the <base> node in index.html.

So, I changed it back to <base href="/"> and the app was working again with ng serve.

Stupid, I know, but maybe helpful for somebody.

Go to project folder and use ng serve --open in Cli that will initate your angular configrtion agian

Related