【问题标题】:.NET Core app on Heroku: Web process failed to bind to $PORT, how to fix?Heroku 上的 .NET Core 应用程序:Web 进程无法绑定到 $PORT,如何修复?
【发布时间】:2018-06-30 22:52:28
【问题描述】:

我使用 git 将我的 asp.net 核心应用程序部署到 heroku。它部署得很好,但是一分钟后它就因为这个错误而崩溃了:

错误 R10(启动超时)-> Web 进程在启动后 60 秒内未能绑定到 $PORT

我用谷歌搜索了它,但只找到了其他平台的解决方案,而不是 .net 核心。我该如何解决这个错误?

我试过这样做,但没有成功

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .UseUrls("http://+:" + System.Environment.GetEnvironmentVariable("PORT"));

    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

【问题讨论】:

    标签: heroku asp.net-core deployment


    【解决方案1】:

    这终于唤醒了我!!!

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .UseKestrel(options =>
                {
                    options.ListenAnyIP(Int32.Parse(System.Environment.GetEnvironmentVariable("PORT")));
                });
    

    【讨论】:

      猜你喜欢
      • 2019-09-02
      • 1970-01-01
      • 2021-02-23
      • 2020-06-10
      • 1970-01-01
      • 2018-05-26
      • 2021-09-17
      • 1970-01-01
      • 2020-02-10
      相关资源
      最近更新 更多