title: Failed to launch debug adapter: VS tries to connect to a random port
body: <p>I have a asp.net core (.net5) project that when I launch it systematically throws errors after a delay, and then closes the debug.</p>
  <p>I have the following launchSettings:</p>
  <pre><code>{
    &quot;iisSettings&quot;: {
      &quot;windowsAuthentication&quot;: true,
      &quot;anonymousAuthentication&quot;: false,
      &quot;iisExpress&quot;: {
        &quot;applicationUrl&quot;: &quot;http://localhost:50868&quot;,
        &quot;sslPort&quot;: 44363
      }
    },
    &quot;profiles&quot;: {
      &quot;IIS Express&quot;: {
        &quot;commandName&quot;: &quot;IISExpress&quot;,
        &quot;launchBrowser&quot;: true,
        &quot;environmentVariables&quot;: {
          &quot;ASPNETCORE_ENVIRONMENT&quot;: &quot;Development&quot;
        }
      },
      &quot;Kestrel&quot;: {
        &quot;commandName&quot;: &quot;Project&quot;,
        &quot;dotnetRunMessages&quot;: &quot;true&quot;,
        &quot;launchBrowser&quot;: true,
        &quot;applicationUrl&quot;: &quot;https://localhost:5001;http://localhost:5000&quot;,
        &quot;environmentVariables&quot;: {
          &quot;ASPNETCORE_ENVIRONMENT&quot;: &quot;Development&quot;
        }
      }
    }
  }
  </code></pre>
  <p>I launch the project in debug mode as &quot;Kestrel&quot;</p>
  <blockquote>
  <p>One or more errors occurred.</p>
  <p>Failed to launch debug adapter.  Additional information may be
  available in the output window.</p>
  <p>Cannot connect to runtime process, timeout after 10000 ms - (reason:
  Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:55743).</p>
  </blockquote>
  <p><a href="https://i.stack.imgur.com/TXg8H.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TXg8H.png" alt="enter image description here" /></a></p>
  <p>It seems it does try to connect to a random port like <code>127.0.0.1:55743</code> when the project is set to launch the browser at <code>https://localhost:5001</code> or 5000
  <a href="https://i.stack.imgur.com/rxOLM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rxOLM.png" alt="enter image description here" /></a></p>
  <p>Seems related to this issue <a href="https://github.com/dotnet/aspnetcore/issues/28113" rel="noreferrer">https://github.com/dotnet/aspnetcore/issues/28113</a></p>
  <p>PS. The debug is working fine with <strong>Edge</strong> (I usually work in <em>Chrome</em>), I suppose there is need to change the browser if you have such issue....</p>