简体   繁体   English

Visual Studio 2019“无法连接到 web 服务器‘IIS Express’”

[英]Visual studio 2019 “Unable to connect to web server 'IIS Express'”

I attempt to lunch my ASP.NET Core project in Microsoft Visual Studio 2019 and got this error: " Unable to connect to web server 'IIS Express '"我尝试在 Microsoft Visual Studio 2019 中使用我的 ASP.NET 核心项目并收到此错误:“无法连接到 web 服务器 'IIS Express '”

  • Visual Studio 2019 Version 16.9.5 Visual Studio 2019 版本 16.9.5
  • .Net 5.0 .Net 5.0

If rebooting fixes this for you, then do this instead:如果重新启动可以为您解决此问题,请改为执行以下操作:

net stop winnat
net start winnat

The problem is that something reserved your desired port and made it unavailable.问题是某些东西保留了您想要的端口并使其不可用。

See https://superuser.com/a/1610009/239292https://superuser.com/a/1610009/239292

I tried this one and it worked for me:我试过这个,它对我有用:

1- Go to ' Debug Properties ' 1-转到“调试属性

2- Find ' Web Server Settings ' 2- 找到“网络服务器设置

3- Change the port in ' App URL ' section and save the changes 3-更改“应用程序 URL ”部分中的端口并保存更改

4- Run the application and the same error will appear again 4- 运行应用程序,同样的错误会再次出现

5- Switch the port back to the original port and save the changes 5-将端口切换回原始端口并保存更改

6- Run the application and enjoy it! 6- 运行应用程序并享受它!

I hope this trick work for you.我希望这个技巧对你有用。

I encountered the same issue, but after few seconds i find out that there is a duplicated sslport, the same sslport being registered for another running app, so when i run another app with the same setting i see this error, you have to change the sslport in the launchsetting.json我遇到了同样的问题,但几秒钟后我发现有一个重复的 sslport,同一个 sslport 正在为另一个正在运行的应用程序注册,所以当我运行另一个具有相同设置的应用程序时,我看到这个错误,你必须更改启动设置中的launchsetting.json 看下面的图片

1- Go to 'Debug Properties', Find 'Web Server Settings', Change the port in 'App URL' section and save the changes 1- 转到“调试属性”,找到“Web 服务器设置”,在“应用程序 URL”部分更改端口并保存更改

In your project folder, delete .vs file, also remove the launch settings file in properties (make sure you copy to a different folder before removing it).在您的项目文件夹中,删除 .vs 文件,同时删除属性中的启动设置文件(确保在删除之前复制到其他文件夹)。

Restart visual studio and your machine if possible.如果可能,重新启动 Visual Studio 和您的机器。 Go to launch setting, check if they are properly configured similar to your prev launch settings.转到启动设置,检查它们是否与您之前的启动设置类似地正确配置。 Run the application in IIS.在 IIS 中运行应用程序。

Should start working.应该开始工作了。

The following fixed the problem for me.以下为我解决了问题。

From my experience this issue appears when the port used is already used by other process.根据我的经验,当使用的端口已被其他进程使用时,会出现此问题。 You will see the following: Error description: The process cannot access the file because it is being used by another process.您将看到以下内容: 错误描述:该进程无法访问该文件,因为它正被另一个进程使用。 (0x80070020) Just choose a port number which free to use and the problem will not occur. (0x80070020) 只要选择一个可以自由使用的端口号就不会出现问题。

To me it has worked by switching the project from Debug to Release and Starting it.对我来说,它通过将项目从调试切换到发布并启动它来工作。 When I switch back to Debug it starts correctly.当我切换回调试时,它会正确启动。 It appears to me that For some reason i had the Release project running so the Debug couldn't start.在我看来,出于某种原因,我运行了发布项目,因此调试无法启动。

I have just an API project.我只有一个 API 项目。 Going to project's Properties\\Debug and unchecking the 'Launch browser' helped.转到项目的 Properties\\Debug 并取消选中“启动浏览器”有帮助。

"

In my case... (Visual Studio 2019, .net 5, blazor wasm project):在我的情况下......(Visual Studio 2019,.net 5,blazor wasm 项目):

  • I did bkp copy of "Properties\launchSettings.json" file and ".vs" folder (just in case)我做了“Properties\launchSettings.json”文件和“.vs”文件夹的 bkp 副本(以防万一)
  • I deleted the "Properties\launchSettings.json" file and open the solution.. This file is recreated with default values...我删除了“Properties\launchSettings.json”文件并打开了解决方案。这个文件是用默认值重新创建的......
  • After that, the error is gone and I was able to run and debug the application normally.之后,错误消失了,我能够正常运行和调试应用程序。

Now you can redo your updates on the "Properties\launchSettings.json" (ie change port).现在您可以在“Properties\launchSettings.json”上重做更新(即更改端口)。

In my case it was the wrong .net6 version.就我而言,这是错误的 .net6 版本。 I work in a project with other developers.我与其他开发人员一起在一个项目中工作。 The main developer switched the project from .net5 to .net6.主要开发人员将项目从 .net5 切换到 .net6。 He has 6.0.3 installed, I have 6.0.2.他安装了 6.0.3,我安装了 6.0.2。 Visual Studio did not show this. Visual Studio 没有显示这一点。 On the console with dotnet run, I get this error message.在使用 dotnet run 的控制台上,我收到此错误消息。

My error message was regarding Kestrel web server: Visual Studio is unable to connect to web server ... the web server is no longer running .我的错误消息是关于 Kestrel web 服务器: Visual Studio is unable to connect to web server ... the web server is no longer running I had to replace applicationUrl values from https://0.0.0.0:5001 to https://localhost:5001 .我不得不将applicationUrl值从https://0.0.0.0:5001替换为https://localhost:5001 I got this error when I updated Visual Studio 2022 to 17.3.0将 Visual Studio 2022 更新到 17.3.0 时出现此错误

If you are like me and have probably tried all the above answers to no avail, here is a final solution that has helped me many times.如果您像我一样,并且可能尝试了上述所有答案都无济于事,那么这里有一个最终解决方案,对我有很多帮助。

Answer: Do not restart your system (did this and it failed to work for me most times), rather, save all your work items, then shut down your system to allow all running process to shut down, then power on again .答:不要重新启动您的系统(这样做并且它大多数时候都无法为我工作),而是保存您所有的工作项目,然后关闭您的系统以允许所有正在运行的进程关闭,然后重新打开电源

If you do a restart, IIS Express may not get shut down completely, therefore, your port will still be used by the process holding on to it.如果您重新启动,IIS Express 可能不会完全关闭,因此,您的端口仍将被保留它的进程使用。

This works for me always这对我总是有用

not sure if this answer will help anybody but I had made changes in appsettings.json file in Asp.net Core (net 6) and forgot to add coma after curly brackets不确定这个答案是否对任何人有帮助,但我在 Asp.net Core(net 6)中的 appsettings.json 文件中进行了更改,忘记在大括号后添加逗号

{
  "AppSetting": {

    "Token":  "MY TOKEN"

  },         ----------------------->here
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}

Hence: you might find your errors in your warnings因此:您可能会在警告中发现错误

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

相关问题 无法连接到 web 服务器“IIS Express” - Unable to connect to web server 'IIS Express' ASP.NET 5 MVC:无法连接到 Web 服务器“IIS Express” - ASP.NET 5 MVC: unable to connect to web server 'IIS Express' 无法连接到 web 服务器 IIS Express - ASP.NET CORE - Unable to connect to web server IIS Express - ASP.NET CORE 无法使用 Visual Studio 2019 连接 MySQL 数据库 - Unable to connect with MySQL database with visual studio 2019 如何在 Visual Studio 2019 中带回 IIS Express 进行调试? - How to bring back IIS Express for Debugging in Visual Studio 2019? 从 Visual Studio 2019 运行时在 IIS Express 上获取 NullReferenceException - Getting NullReferenceException on IIS Express while running from Visual Studio 2019 将Visual Studio与Web服务器连接 - Connect Visual Studio with Web Server 未找到 Visual Studio 2019 本地 IIS Web 站点 - Visual Studio 2019 not found local IIS Web Site 在 docker 中运行 Visual Studio 2019 .net web 应用程序无法连接到外部 MySql 服务器 - Running Visual Studio 2019 .net web app in docker can't connect to external MySql server 无法在Visual Studio 2017 RC中启动IIS Express - Unable to launch IIS Express in Visual Studio 2017 RC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM