title: Deploy Net core 5.0 API failed on Heroku with Docker Error: Unable to start Kestrel
body: <p>I try to Deploy Net core 5.0 API on Heroku and get this error:
  Unable to start Kestrel.
  System.FormatException: Invalid url: '3689' the number &quot;3689&quot; changes any time that deploy a new version of my API.</p>
  <p>this is my docker file:</p>
  <pre><code> FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
   WORKDIR /src
   COPY Sporteate.API.csproj .
   RUN dotnet restore
   COPY . .
   RUN dotnet publish -c Release -o /app
   FROM mcr.microsoft.com/dotnet/aspnet:5.0
   WORKDIR /app
   COPY --from=build-env /app .
   ENTRYPOINT [&quot;dotnet&quot;, &quot;Sporteate.API.dll&quot;]
   CMD ASPNETCORE_URLS=http://*:$PORT dotnet Sporteate.API.dll
  </code></pre>
  <p>this is my program file:</p>
  <pre><code>public class Program
  {
      private static readonly ILog log = LogManager.GetLogger(typeof(Program));
      public static void Main(string[] args)
      {
          try
          {
              XmlDocument log4netConfig = new XmlDocument();
              log4netConfig.Load(File.OpenRead(&quot;log4net.config&quot;));
              log4net.Config.XmlConfigurator.Configure(log4net.LogManager.GetRepository(Assembly.GetEntryAssembly()), log4netConfig[&quot;log4net&quot;]);
              CreateHostBuilder(args).Build().Run();
          }catch(Exception ex)
          {
              log.Error(ex.Message);
          }
  
      }
  
      public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
       
         Host.CreateDefaultBuilder(args)
             .ConfigureWebHostDefaults(webBuldier =&gt;
             {
                 var port = Environment.GetEnvironmentVariable(&quot;PORT&quot;);
                 webBuldier.UseStartup&lt;Startup&gt;().UseUrls(&quot;http://*:&quot; + port!=null? port : &quot;44308&quot;);
             });
  
  }
  </code></pre>
  <p>and this is my Heroku's dynos configuration:</p>
  <pre><code> web /bin/sh -c ASPNETCORE_URLS\=http://\*:\$PORT\ dotnet\ Sporteate.API.dll
  </code></pre>