Connection refused: localhost:4200 favicon.ico 502

2019-08-17 22:34发布

I have create an angular project via

ng new project_name --style=scss

and then try to run via

ng serve

but getting error

enter image description here

enter image description here

removed and reinstalled the node_modules but all in vain.

Every time getting this error, please guide what to do!!!

UPDATE 1

Why I am not able to run Angular application on localhost (running on 192.168.X.X:4200) in my office pc but the same project I can run on localhost at my home

UPDATE 2

in hosts file, I have this. Is it OK?

127.0.0.1 localhost

::1 localhost

Update 3

I am quite sure, it is only the system config issue that's why it is blocking localhost and allowing 192.168.X.X but don't know where the problem lies.

5条回答
SAY GOODBYE
2楼-- · 2019-08-17 22:55

Just put your favicon.ico file to your project root directory and update your favicon file inject code with the below code in the head of your index.html file. Thanks

<link rel="icon" href="favicon.ico" type="image/x-icon">
查看更多
看我几分像从前
3楼-- · 2019-08-17 23:00

There is no Angular CLI command such as npm start, Did you mean that?

ng serve

Please check this out, https://angular.io/cli/serve

查看更多
4楼-- · 2019-08-17 23:01

You can use the following method to solve the same :

  • Check your LAN proxy settings.

    In chrome Settings -> Advanced -> Open Proxy Settings -> LAN Settings -> make sure you unchecked "use proxy server for your LAN" or mark "bypass proxy server for local address" if you are using proxy

enter image description here

Also if the above settings didn't solve your problem probably the port 4200 is already used in the system try running app on a different port ng serve --port 4401

Also make sure you clear browser cache to see the result

查看更多
叼着烟拽天下
5楼-- · 2019-08-17 23:11

I was using Opera browser for testing and it was my default browser and trying to access localhost:4200 but every time connection refused then I test this on Chrome, it ran smoothly.

I checked proxy setting for both the browsers and there was no proxy enabled. Finally I reset data in Opera and problem resolved.

Still, question is there!!! What was that hindering localhost ...

查看更多
Animai°情兽
6楼-- · 2019-08-17 23:18

Put your favicon.ico file in assets folder and change the path in the index.html

查看更多
登录 后发表回答