ASP.NET Core Web API - Unable to connect to web server 'IIS Express'
When I open my ASP.NET CORE Web API (3.1) project in Visual Studio 2019, I got this error.
Microsoft Visual Studio
Unable to connect to web server ‘IIS Express’.
- Change the port of the
sslPortof IISExpress. (This setting is in
\Properties\launchSettings.json. ) Please refer the screenshow below.
- Close the Visual Studio and reopen it again. You shouldn’t see that error anymore.
Note: I think there might be other projects that are using the same port in IIS express so you might be getting this issue. I haven’t looked at it in deep yet since its already happened once. If I or someone in my team get more of this error then I will probably spend more time to dig more about the root cause.
“This site can’t be reached” error
You might get this “This site can’t be reached” when you run the Web API with https enabled. but you should be able to run it with http URL.
In that case, the solution that I found is as below.
- Create a new Web API project with https enabled
- Copy the
sslPort(let’s see 44307) of that new project
- Use that new port (e.g. 44307) in your project.
- Close/delete your new project
Hope it helps.