Michael Sync

Michael Sync

Crisp, minimal personal blog

14 Sep 2021

ASP.NET Core Web API - Unable to connect to web server 'IIS Express'


Problem

When I open my ASP.NET CORE Web API (3.1) project in Visual Studio 2019, I got this error.

Unable to connect to web server ‘IIS Express’

Error Message

Microsoft Visual Studio

Unable to connect to web server ‘IIS Express’.

OK

Solution

  • Change the port of the applicationUrl and sslPort of IISExpress. (This setting is in \Properties\launchSettings.json. ) Please refer the screenshow below. Unable to connect to web server ‘IIS Express’
  • 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.