Failed to launch debug adapter: VS tries to connect to a random port

  Uncategorised

I have a asp.net core (.net5) project that when I launch it systematically throws errors after a delay, and then closes the debug.

I have the following launchSettings:

{
  "iisSettings": {
    "windowsAuthentication": true,
    "anonymousAuthentication": false,
    "iisExpress": {
      "applicationUrl": "http://localhost:50868",
      "sslPort": 44363
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Kestrel": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

I launch the project in debug mode as "Kestrel"

One or more errors occurred.

Failed to launch debug adapter. Additional information may be
available in the output window.

Cannot connect to runtime process, timeout after 10000 ms – (reason:
Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:55743).

enter image description here

Why does it try to connect to a random port like 127.0.0.1:55743 when the proejct is set to launch the browser at https://localhost:5001?

enter image description here

Source: Visual Studio Questions

One Reply to “Failed to launch debug adapter: VS tries to connect to a random port”

  • I am having this issue after updating to the latest version of Windows : Windows 10 Pro version 20H2. OS BUILD 19042.867.

    It’s only throwing the error if Edge is the debug browser. Changing it to Firefox, Brave, and even Internet Explorer works fine.

    Indicates to me that there is a bug in the Edge browser.

LEAVE A COMMENT