title: How to change the default port in asp.net Core 3 or Net Core 5
body: <p>when I am in debug, to change the default port, I modify the launchSettings.json file, and change the port</p>
  
  <pre><code>"WebApplication1": {
        "commandName": "Project",
        "launchBrowser": true,
        "launchUrl": "weatherforecast",
        "environmentVariables": {
          "ASPNETCORE_ENVIRONMENT": "Development"
        },
        "applicationUrl": "https://*:8081;http://*:8080"
      }
  </code></pre>
  
  <p>but if I publish the application in a folder (selfHost) and launch the executable, it always listens on port 5000
  Someone knows how to change the default port in production.
  I tried changing it in the program.cs with <strong>UseUrls</strong> but not working</p>
  
  <pre><code>public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
              Host.CreateDefaultBuilder(args)
                  .ConfigureServices((hostContext, services) =&gt;
                  {
                      services.AddHostedService&lt;Worker&gt;();
                  }).UseWindowsService()
                  .ConfigureWebHostDefaults(webBuilder =&gt;
                  {
                      webBuilder.UseStartup&lt;Startup&gt;()
                      .UseUrls("http://*:8080","https://*:8081");
                  })
              .UseSerilog();
  </code></pre>