Unable to connect to web server
Asked Answered
S

4

0

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.

Serin answered 30/3, 2018 at 14:26 Comment(3)
How long has the issue been going on? Any recent Windows updates that might account for the behavior? Any chance it's TLS/SSL-related (I haven't done any web development, so forgive my ignorance).Basilisk
I haven't had any updates recently. The problem started two hours ago. Can you be more specific about TLS/SSL errors?Serin
Post what VS Diag reports. Otherwise, readers of this question don't even know what are the settings on your machine. We have no magic to guess remotely. jexusmanager.com/en/latest/tutorials/vs-diagnostics.htmlInsomnolence
V
2
  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
Vashti answered 8/5, 2020 at 5:39 Comment(1)
Point number six helps me to resolve this issue.Gredel
D
1

I know this question has been addressed numerous times, but I haven't seen anything with regards to CORE 6.0 so I'll mention it here as I had a similar problem.

I registered new files with the DI container and then all of a sudden, the issue appeared. After doing all the usual things, I set break points in my program.cs file and found an exception was being raised (during builder.Build()) due to the DI container not being able to resolve type dependancies during startup. Once this issue was resolved, everything worked as expected.

Hopefully this info may be useful when all other attempts fail.

Donell answered 13/10, 2023 at 11:49 Comment(0)
T
0

For this particular error please make sure that your configuration in appsettings.json file is correct. Verify that there are no duplicate key or error is there.

I also faced the same issue, and after some investigation I found that my appsettings.json file contains some duplicate entries there. Removing those duplicate entries resolved my problem.

Tragus answered 10/4 at 9:24 Comment(0)
I
0
  1. Go to C:\Users\username\Documents\IISExpress\config and delete all files from this folder
  2. Rebuild VS solution
Illene answered 19/7 at 18:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.