title: How can I configure endpoints in Kestrel?
body: <p>I'm learning how to work with in ASP.NET Core 2 and I've come across a rather annoying problem. Whenever I run my application, the Kestrel server ignores my endpoint configuration and instead starts listening on a random port. Needless to say, this is not the behavior I expected. When digging through the server logs I also came upon this message:</p>
  
  <pre><code>Overriding endpoints defined in UseKestrel() because PreferHostingUrls is set to true. Binding to address(es) 'http://localhost:&lt;some random port&gt;' instead.
  </code></pre>
  
  <p>I have so far been unable to find any documentation on this "PreferHostingUrls" setting or how to change it. Does anyone know how i can configure Kestrel to listen on the specified port instead of a random one?</p>
  
  <p>My host configuration looks like this:</p>
  
  <pre><code>WebHost.CreateDefaultBuilder(args)
          .UseConfiguration(config)
          .UseKestrel(
              options =&gt;
              {
                  options.Listen(IPAddress.Loopback, 50734);
                  options.Listen(IPAddress.Loopback, 44321, listenOptions =&gt;
                  {
                      listenOptions.UseHttps("pidea-dev-certificate.pfx", "****************");
                  });
              })
          .UseStartup&lt;Startup&gt;()
          .UseIISIntegration()
          .Build();
  </code></pre>