asp.net-mvc 本地主机拒绝连接 Visual Studio 中的错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37352603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-07 23:32:48  来源:igfitidea点击:

localhost refused to connect Error in visual studio

asp.net-mvcvisual-studioiis-express

提问by duke

I have copied my solution file from another system and tried to run it on my machine: For this, I have gone to the project folder and deleted the previous solution file and copied the new one.

我已经从另一个系统复制了我的解决方案文件并尝试在我的机器上运行它:为此,我已经转到项目文件夹并删除了以前的解决方案文件并复制了新的解决方案文件。

Now, it started giving me error. connection refused etc. So, I got one solution from here: How to solve ERR_CONNECTION_REFUSED when trying to connect to localhost running IISExpress - Error 502 (Cannot debug from Visual Studio)?

现在,它开始给我错误。连接被拒绝等。所以,我从这里得到了一个解决方案:尝试连接到运行 IISExpress 的本地主机时如何解决 ERR_CONNECTION_REFUSED - 错误 502(无法从 Visual Studio 调试)?

According to it, I changed the port number from 1049 to 1052. It loaded and one of the pages gets loaded. But when I entered the desired login credentials then it redirected to the older port again, like this:

根据它,我将端口号从 1049 更改为 1052。它已加载并加载了其中一个页面。但是当我输入所需的登录凭据时,它再次重定向到旧端口,如下所示:

http://localhost:1049/Home/SearchFlight

and the error is:

错误是:

 This site can't be reached

 localhost refused to connect.
 Search Google for localhost 1049 Home Search Flight
 ERR_CONNECTION_REFUSED

Now, I don't know what to do from here. I have changed the port number to 1052 but still its pointing to 1049. What should i do now?

现在,我不知道该怎么办。我已将端口号更改为 1052,但仍指向 1049。我现在该怎么办?

回答by Kush

I had a similar issue. Try this and it should work

我有一个类似的问题。试试这个,它应该可以工作

  1. Go to your project folder and open the .vsfolder (keep your check hidden item-box checked as this folder may be hidden sometimes)

  2. In the .vsfolder open the configfolder

  3. See that applicationhost.configfile there? Delete that thing. (Do not worry it will regenerate automatically once you recompile the project.)

  1. 转到您的项目文件夹并打开该.vs文件夹(保持选中隐藏项目框,因为该文件夹有时可能被隐藏)

  2. .vs文件夹中打开config文件夹

  3. 看到那个applicationhost.config文件了吗?删除那个东西。(不要担心它会在您重新编译项目后自动重新生成。)

回答by Dmitry Pavlov

Usually on local machine we are getting errors like This site can't be reached localhost refused to connectbecause we have self signed certificate configuration broken for local IIS Express.?Sometimes it happens when you change URLs in launchSettings.jsonor never configured self signed certificates on this machine at all.

通常在本地机器上,我们会收到错误,例如This site can't be reached localhost refused to connect因为我们为本地 IIS Express 设置了自签名证书配置。有时当您更改 URLlaunchSettings.json或从未在此计算机上配置自签名证书时会发生这种情况。

To fix self-signed certificate on the local machineyou need to:?

在本地计算机上修复自签名证书,您需要:?

  1. Delete .vs folder (requires to close Visual Studio 2017)
  2. Run these commands in cmdAs Administrator:

    cd "C:\Program Files (x86)\IIS Express"

    IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:12345/ -UseSelfSigned

  3. Make sure you run VS2017 As Administratorand check if the issue addressed

  1. 删除 .vs 文件夹(需要关闭 Visual Studio 2017)
  2. 在 中运行这些命令cmdAs Administrator

    cd "C:\Program Files (x86)\IIS Express"

    IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:12345/ -UseSelfSigned

  3. 确保您运行 VS2017As Administrator并检查问题是否已解决

Note: https://localhost:12345/is what is in your launchSettings.jsonfor HTTPS

注意:https://localhost:12345/是什么在你launchSettings.jsonHTTPS

回答by vinayak hegde

Changing port number has resolved the issue

更改端口号已解决问题

enter image description here

在此处输入图片说明

回答by Pradeep Kumar Das

Just Delete the (obj)Object folder in project folder then Run the application then It will work fine. Steps:

只需删除项目文件夹中的 (obj)Object 文件夹,然后运行应用程序即可。脚步:

  1. Right Click on the project folder then select "Open folder in file Explorer".
  2. Then Find the Obj folder and Delete that.
  3. Run the Application.
  1. 右键单击项目文件夹,然后选择“在文件资源管理器中打开文件夹”。
  2. 然后找到 Obj 文件夹并删除它。
  3. 运行应用程序。

回答by Baqer Naqvi

I had the same problem. Deleting .vsfolder (including all contents, folder might be hidden) worked for me.

我有同样的问题。删除.vs文件夹(包括所有内容,文件夹可能被隐藏)对我有用。

回答by Watusimoto

I solved a similar problem by listing bound IP addresses in a cmd window running as admin:

我通过在以管理员身份运行的 cmd 窗口中列出绑定的 IP 地址解决了类似的问题:

netsh http show iplisten

Then, one by one, blowing them all away:

然后,一个一个,把它们全部吹走:

netsh http delete iplisten ipaddress=127.0.0.200
netsh http delete iplisten ipaddress=127.0.0.2
...

回答by Shane

Unfortunately, none of these answers worked for me. This answer finally did for Chrome only. Unfortunately, you have to do it each time:

不幸的是,这些答案都不适合我。这个答案最终只适用于 Chrome。不幸的是,您每次都必须这样做:

  1. Open this in your browser: chrome://net-internals/#hsts
  2. Go to Delete domain security policies
  3. Enter "localhost"
  4. Restart browser
  1. 在浏览器中打开它:chrome://net-internals/#hsts
  2. 转到删除域安全策略
  3. 输入“本地主机”
  4. 重新启动浏览器

Google Chrome redirecting localhost to https

谷歌浏览器将本地主机重定向到 https

回答by anu

I ran my Visual Studio as "Run as administrator" and this solved my problem.

我以“以管理员身份运行”的身份运行 Visual Studio,这解决了我的问题。

回答by R. Salisbury

I was having this issue and solved it by closing all open instances of Visual Studio.

我遇到了这个问题,并通过关闭所有打开的 Visual Studio 实例来解决它。

回答by developer0817

Change the port number and remove script debugging (if enabled) to resolve in localhost.

更改端口号并删除脚本调试(如果启用)以在localhost.