[英]Connection refused: localhost:4200 favicon.ico 502 in angular 7
I have create an angular project via我通过创建一个角度项目
ng new project_name --style=scss
and then try to run via然后尝试通过运行
ng serve
but getting error但得到错误
removed and reinstalled the node_modules
but all in vain.删除并重新安装了node_modules
但都是徒劳的。
Every time getting this error, please guide what to do!!!每次出现这个错误,请指导怎么办!!!
UPDATE 1更新 1
Why I am not able to run Angular
application on localhost
(running on 192.168.XX:4200) in my office pc but the same project I can run on localhost
at my home为什么我无法在办公室电脑的localhost
上运行Angular
应用程序(在 192.168.XX:4200 上运行),但我可以在家里的localhost
上运行同一个项目
UPDATE 2更新 2
in hosts file, I have this.在主机文件中,我有这个。 Is it OK?可以吗?
127.0.0.1 localhost 127.0.0.1 本地主机
::1 localhost ::1 本地主机
Update 3更新 3
I am quite sure, it is only the system config issue that's why it is blocking localhost and allowing 192.168.XX but don't know where the problem lies.我很确定,这只是系统配置问题,这就是为什么它阻止 localhost 并允许 192.168.XX 但不知道问题出在哪里。
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.我正在使用Opera
浏览器进行测试,它是我的默认浏览器并尝试访问localhost:4200
但每次connection refused
然后我在Chrome
上测试它时,它运行顺利。
I checked proxy setting for both the browsers and there was no proxy enabled.我检查了两个浏览器的代理设置,但没有启用代理。 Finally I reset settings and data in Opera
and problem resolved.最后我在Opera
重置了设置和数据并解决了问题。
Still, question is there!!!还是,问题来了!!! What was that hindering localhost
...是什么阻碍了localhost
......
I also faced the same issue.我也面临同样的问题。 I tried the above solutions, it didn't work.我尝试了上述解决方案,但没有奏效。 I am using a different port now.我现在使用不同的端口。 I used this command:我使用了这个命令:
-ng serve --port 0
and I could see my app running on the new port.我可以看到我的应用程序在新端口上运行。
There is no Angular CLI command such as npm start, Did you mean that?没有像 npm start 这样的 Angular CLI命令,你是这个意思吗?
ng serve
Please check this out, https://angular.io/cli/serve请检查一下, https://angular.io/cli/serve
将您的 favicon.ico 文件放在 assets 文件夹中并更改 index.html 中的路径
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.只需将您的favicon.ico
文件放入您的项目根目录,并在您的index.html
文件的head
使用以下代码更新您的favicon
文件注入代码。 Thanks谢谢
<link rel="icon" href="favicon.ico" type="image/x-icon">
You can use the following method to solve the same :您可以使用以下方法来解决相同的问题:
Check your LAN proxy settings.检查您的 LAN 代理设置。
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在 Chrome 设置 -> 高级 -> 打开代理设置 -> LAN 设置 -> 确保取消选中“为 LAN 使用代理服务器”或标记“绕过本地地址的代理服务器”(如果您使用代理)
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
此外,如果上述设置没有解决您的问题,可能系统中已经使用了端口4200
尝试在不同的端口上运行应用程序ng serve --port 4401
Also make sure you clear browser cache to see the result还要确保清除浏览器缓存以查看结果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.