title: Self-hosting ASP.NET Core Web API is causing an error - No connection could be made because the target machine actively refused it
body: <p>I am self-hosting an ASP.NET Core 3.1 Web API application using <code>https</code> options. </p>
  
  <p>These are my hosted server details</p>
  
  <ul>
  <li>Computer Name: padevspal203</li>
  <li>Domain Name: padev.local</li>
  </ul>
  
  <p>Now I created a self signed certificate using this PowerShell command,</p>
  
  <pre><code>New-SelfSignedCertificate -DnsName PADEVSPAL203.PADEV.LOCAL -CertStoreLocation cert:\LocalMachine\My
  </code></pre>
  
  <p>Also exporting certificate and place in C: drive.</p>
  
  <p>Here is code for creating host builder with Kestrel configuration,</p>
  
  <pre><code>public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
          Host.CreateDefaultBuilder(args)
              .ConfigureWebHostDefaults(webBuilder =&gt;
              {
                  webBuilder.ConfigureKestrel(serverOptions =&gt;
                      {
                          serverOptions.AddServerHeader = false;
                          serverOptions.Listen(IPAddress.Loopback, 44321, listenOptions =&gt;
                          {
                              listenOptions.UseHttps(new X509Certificate2(@"C:\cert\test.pfx", "Password1"));
                          });
                      })
                      .UseStartup&lt;Startup&gt;();
              });
  </code></pre>
  
  <p>Now when trying to browse api get method,getting below error. What wrong here?</p>
  
  <pre><code>https://PADEVSPAL203.PADEV.LOCAL:44321/WeatherForecast
  </code></pre>
  
  <blockquote>
    <p>[Fiddler] The connection to 'padevspal203.padev.local' failed. </p>
    
    <p>Error: ConnectionRefused (0x274d). 
    System.Net.Sockets.SocketException No connection could be made because the target machine actively refused it [2002:aca8:2a2::aca8:2a2]:44321                                                                                                                                                                                                                                                                     </p>
  </blockquote>