title: Unable to start Kestrel. System.IO.IOException: Failed to bind to address http://127.0.0.1:5000: address already in use
body: <p>I followed the steps from this URL to publish .NET core 2.1 web application code to Linux Centos 7 server. </p>
  
  <p><a href="https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2</a></p>
  
  <p>I tried to run "sudo dotnet application_name.dll". I received this following error message. Am I missing something? I published code using Visual Studio 2017 on windows machine and copied code to Linux server.</p>
  
  <pre><code>crit: Microsoft.AspNetCore.Server.Kestrel[0]
        Unable to start Kestrel.
  System.IO.IOException: Failed to bind to address http://127.0.0.1:5000: address already in use. ---&gt; Microsoft.AspNetCore.Connections.AddressInUseException: Address already in use ---&gt; System.Net.Sockets.SocketException: Address already in use
  </code></pre>
  
  <h2> Program.cs</h2>
  
  <pre><code>  public class Program
      {
          public static void Main(string[] args)
          {
              CreateWebHostBuilder(args).Build().Run();
          }
  
          public static IWebHostBuilder CreateWebHostBuilder(string[] args) =&gt;
              WebHost.CreateDefaultBuilder(args)
                  .UseStartup&lt;Startup&gt;();
      }
  </code></pre>
  
  <h2>Startup.cs config</h2>
  
  <pre><code> public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
          app.UseStaticFiles();
  
          app.UseMvc(routes =&gt;
          {
              routes.MapRoute(
                  name: "default",
                  template: "{controller=Home}/{action=Index}/{id?}");
          });
  
          app.UseForwardedHeaders(new ForwardedHeadersOptions
          {
              ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
          });
      }
  </code></pre>
  
  <p>launchSettings.json:</p>
  
  <pre><code>  "applicationUrl": "https://localhost:5001;http://localhost:5000"
  </code></pre>