Developing Web API in C# with VS 2022: IIS Express Error, no connection to local IP, access denied

Georg Aubele Lehmbau 0 Reputation points
2024-03-07T11:53:07.5333333+00:00

I'm developing a Web API with C#, Net 8, in Visual Studio 2022.

Everything was fine until I changed one detail in

"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
  "windowsAuthentication": false,
  "anonymousAuthentication": true,
  "iisExpress": {
    "applicationUrl": "http://localhost:20040",
    "sslPort": 44363
  }

I changed localhost to an local IP, let's say 192.168.188.3, in order to test access from my laptop. Starting the debug mode, I got an message window with an error message:

(I'm translating from German, so the actual text could differ from the english message)

'No connection could be established to webserver IIS Express. [...] Failed to register URL "http://192.168.188.3:20040/" for site "MyAPI application /". Error description: access denied (0x80070005)'

I changed the line to its former value, but the error message comes up again and again as soon as I start the debug process. The IP does not exist in the whole source code anymore!

I already tried to delete '%USERPROFILE%\AppData\Local\Temp\IISExpress' and I also read the question https://learn.microsoft.com/en-us/answers/questions/1191901/unable-to-launch-iis-express-web-server but the solutions mentioned there do not seem to work with an API project.

Internet Information Services
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
297 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sam Wu-MSFT 7,036 Reputation points Microsoft Vendor
    2024-03-12T09:53:43.69+00:00

    @Georg Aubele Lehmbau

    You can try to open properties page of your web application and make it use some available port that is not in port exclusion range.

    After changing port click also on Create Virtual Directory button.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.