【问题标题】:Microsoft.AspNetCore.Server.Kestrel[0] Unable to start KestrelMicrosoft.AspNetCore.Server.Kestrel[0] 无法启动 Kestrel
【发布时间】:2022-01-07 15:15:26
【问题描述】:

当我运行我的镜像 docker 时,他给了我这个错误

Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to start Kestrel.
System.InvalidOperationException: HTTPS endpoints can only be configured using KestrelServerOptions.Listen().
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAddressAsync(String address, AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, List`1 listenOptions, ILogger logger, Func`2 createBinding)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)

Unhandled Exception: System.InvalidOperationException: HTTPS endpoints can only be configured using KestrelServerOptions.Listen().
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAddressAsync(String address, AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, List`1 listenOptions, ILogger logger, Func`2 createBinding)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at Btorport.Web.Program.Main(String[] args) in /App/Btorport.Web/Program.cs:line 13

我认为证书有问题,所以我删除并在我的项目中通过执行此命令从新添加-->

dotnet dev-certs https --clean
dotnet dev-certs https
dotnet dev-certs https --trust

但是我没有在我的项目中使用 kestrul 我不知道为什么给我这个错误??

&这是我的 BuildWebHost 方法

 return WebHost.CreateDefaultBuilder(args)
                .UseUrls("http://*:5050;https://*:5050")
                  .UseStartup<Startup>()
                  .Build();

【问题讨论】:

标签: c# docker .net-core


【解决方案1】:

您指定它应该为 http 和 https 使用端口 5050。那是不可能的。它需要是不同的端口。

例如

return WebHost.CreateDefaultBuilder(args)
                .UseUrls("http://*:5050;https://*:5051")
                  .UseStartup<Startup>()
                  .Build();

【讨论】:

    猜你喜欢
    • 2020-04-20
    • 1970-01-01
    • 2021-12-12
    • 2021-02-04
    • 2023-03-23
    • 2019-02-08
    • 2020-04-30
    • 2017-07-18
    • 1970-01-01
    相关资源
    最近更新 更多