简体   繁体   中英

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 '"

  • Visual Studio 2019 Version 16.9.5
  • .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/239292

I tried this one and it worked for me:

1- Go to ' Debug Properties '

2- Find ' Web Server Settings '

3- Change the port in ' App URL ' section and save the changes

4- Run the application and the same error will appear again

5- Switch the port back to the original port and save the changes

6- Run the application and enjoy it!

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 看下面的图片

1- Go to 'Debug Properties', Find 'Web Server Settings', Change the port in 'App URL' section and save the changes

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

Restart visual studio and your machine if possible. Go to launch setting, check if they are properly configured similar to your prev launch settings. Run the application in 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.

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. Going to project's Properties\\Debug and unchecking the 'Launch browser' helped.

"

In my case... (Visual Studio 2019, .net 5, blazor wasm project):

  • I did bkp copy of "Properties\launchSettings.json" file and ".vs" folder (just in case)
  • I deleted the "Properties\launchSettings.json" file and open the solution.. This file is recreated with default values...
  • 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).

In my case it was the wrong .net6 version. I work in a project with other developers. The main developer switched the project from .net5 to .net6. He has 6.0.3 installed, I have 6.0.2. Visual Studio did not show this. On the console with dotnet run, I get this error message.

My error message was regarding Kestrel web server: 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 . I got this error when I updated Visual Studio 2022 to 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.

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

{
  "AppSetting": {

    "Token":  "MY TOKEN"

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

Hence: you might find your errors in your warnings

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