简体   繁体   English

Localhost拒绝连接.NET Core Web API

[英]Localhost refused to connect .NET Core Web API

when I am trying to launch my .Net Core WebApi project I receive System.Net.Sockets.SocketException No connection could be made because the target machine actively refused it 127.0.0.1:50620 error from Fiddler (in other words localhost refused to connect in browser). 当我尝试启动.Net Core WebApi项目时,我收到System.Net.Sockets.SocketException No connection could be made because the target machine actively refused it 127.0.0.1:50620来自Fiddler的System.Net.Sockets.SocketException No connection could be made because the target machine actively refused it 127.0.0.1:50620错误(换句话说,本地主机拒绝连接浏览器)。

I know there are thousands of questions about this issue but neither one of them managed to fix my problem. 我知道关于这个问题有成千上万的问题,但是没有一个人能解决我的问题。

What I did so far: 到目前为止,我做了什么:

  • Played with hosts file of Windows - this seemed not to be the case. 玩过Windows的hosts文件-似乎并非如此。

  • Made another project that use same port - results were it builds with no problems so I concluded there no problems with this specific port.(Despite that I tried changing my port , but no success.) 制作了另一个使用相同端口的项目-结果是它的构建没有问题,所以我断定该特定端口没有问题。(尽管我尝试更改端口,但没有成功。)

  • Checked all my project/application settings files for any differences that might be causing the problem between the project I am failing to build and the one template project I am building successfully. 检查我所有的项目/应用程序设置文件中可能导致我无法构建的项目与成功构建的一个模板项目之间的问题的任何差异。 - there are none drastic differences. -没有太大的差异。

  • Turned off my firewall so I can check if firewall is the problem of this - project failed to build with firewall off. 关闭防火墙,以便检查防火墙是否是此问题-在关闭防火墙的情况下无法建立项目。

  • Deleted temporary .NET files and assemblies related to the project. 删除与项目相关的临时.NET文件和程序集。

  • Used netstat to see if someone is already listening to that port. 使用netstat查看是否有人已经在监听该端口。 - doesn't seem to be the case give the fact that I can build another project using the same port. -似乎并非如此,我可以使用相同的端口构建另一个项目。

After one week of searching answers in internet and stackoverflow in general I am still stuck so I will be glad to use an extra hand to fix this. 经过一个星期的互联网和stackoverflow搜索答案后,我仍然很困惑,因此我很乐意多用一只手来解决这个问题。

If you need anything else as information for instance content of project.json file, applicationhost.json, etc. please write a comment and I will provide all the information I can in order to fix this. 如果您需要其他任何信息作为project.json文件,applicationhost.json等实例内容的信息,请写评论,我将提供所有可能的信息以解决此问题。

This problem occures because you do not have a certificate for localhost. 发生此问题,因为您没有本地主机的证书。

You have to install a self signed certificate for localhost . 您必须为localhost安装一个自签名证书。 Then you would only get ERR_INSECURE_RESPONSE which can be turned of in the browser settings. 然后,您只会得到ERR_INSECURE_RESPONSE ,可以在浏览器设置ERR_INSECURE_RESPONSE其打开。

To get rid of all errors you have to install a localhost certificate which has a trusted root authority. 要摆脱所有错误,您必须安装具有受信任的根权限的localhost证书。


Another option is explained here . 这里介绍另一个选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM