'Unable to connect to web server

I know that this problem has been discussed here a lot of times before but believe me I've tried every single one of them and I still have this issue.

As a last resort before pulling my hair I decided to ask the question again and explain what I have tried so far:

  1. The first thing I have tried is to to remove .vs folder from the project as I read about it somewhere here.
  2. I have deleted the .vs folder started Visual Studio as administrator and changed the port number.
  3. I deleted IISExpress folder from [Documents]/IISExpress
  4. At this point I was pretty pissed off so I uninstalled and reinstalled Visual Studio 2017 Enterprise.
  5. I uninstalled and reinstalled IISExpress 10
  6. I uninstalled IISExpress 10 and installed IISExpress 8
  7. I put 127.0.0.1 localhost to my host file (It was not there before)

Nothing here did solved my problem so at this point I am pretty desperate and open to any kind of suggestions.

I am using Windows 10 with Visual Studio 2017 and cannot run any of the projects neither debug nor without debug mode. I am getting the same error all the time - Unable to connect to web server.

Any help is appreciated. Thank you in advance.



Solution 1:[1]

  1. Clean and Rebuild Projects dependencies
  2. Clean and Rebuild the primary project
  3. Verify launchsettings and project build properties
  4. Close VS
  5. Clear bin and obj folders from project
  6. Go to C:\Users\username\Documents\IISExpress\config and delete all files from this folder
  7. Remove the .VS folder from the solution directory
  8. Verify the launchsettings.json has the correct format/syntax. You must have this applicationUrl listed in correct location like below:

Also you can use netstat to see all the ports in use; be aware that you must look at all IIS Express ports you use, and all local IIS ports.

Understanding that IIS will listen on one port, and reverse proxy to another port where the Kestrel server is listening.

{
  "IIS Express": {
    "commandName": "IISExpress",
    "launchBrowser": true,
    "launchUrl": "api/values",
    "environmentVariables": {
      “ASPNETCORE_ENVIRONMENT": "Development"
    },
    "applicationUrl": "http://localhost:44316/"
  }
}
  1. Restart Visual Studio, ensuring that you are running as Administrator
  2. Clean and Rebuild Projects dependencies
  3. Clean and Rebuild the primary project

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeremy Caney