简体   繁体   中英

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).

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.

  • 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.

  • Used netstat to see if someone is already listening to that port. - 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.

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.

This problem occures because you do not have a certificate for localhost.

You have to install a self signed certificate for localhost . Then you would only get ERR_INSECURE_RESPONSE which can be turned of in the browser settings.

To get rid of all errors you have to install a localhost certificate which has a trusted root authority.


Another option is explained here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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