简体   繁体   English

连接被拒绝:localhost:4200 favicon.ico 502 in angular 7

[英]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.

相关问题 Angular favicon.ico 未显示 - Angular favicon.ico is not showing 如何更改 Angular 中的 favicon.ico 路径? - How to change favicon.ico path in Angular? 无法在重新加载页面上获取 /login Angular 8 - 拒绝加载图像“/favicon.ico”,因为它违反了以下内容安全策略 - Cannot GET /login on reload pages Angular 8 - Refused to load the image '/favicon.ico' because it violates the following Content Security Policy 我的 angular 项目从哪里获取 A favicon.ico? 它不在我的项目中 - Where is my angular project picking up the A favicon.ico from? It's not in my project 错误:EACCES:权限被拒绝,取消链接“/Users/marina/Desktop/PO/angular-po/dist/angular-po/favicon.ico” - Error: EACCES: permission denied, unlink '/Users/marina/Desktop/PO/angular-po/dist/angular-po/favicon.ico' “连接被拒绝” Angular 4 本地主机开发 - "Connection refused" Angular 4 localhost development 在Angular 5中将localhost:4200更改为mysite:4200 - Change localhost:4200 to something mysite:4200 in Angular 5 localhost:4200是Angular中的空白页 - localhost:4200 is a blank page in Angular localhost 和 localhost:4200 CORS 问题在 angular - localhost and localhost:4200 CORS issue in angular localhost:4200 不适用于我的 Angular 应用程序 - localhost:4200 not working for my angular app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM