我按照此URL上的步骤将.NET core 2.1 Web应用程序代码发布到Linux Centos 7服务器。
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2
我试图运行“ sudo dotnet application_name.dll”。我收到以下错误消息。我想念什么吗?我在Windows计算机上使用Visual Studio 2017发布了代码,然后将代码复制到Linux服务器。
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. ---> Microsoft.AspNetCore.Connections.AddressInUseException: Address already in use ---> System.Net.Sockets.SocketException: Address already in use
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
}
launchSettings.json:
"applicationUrl": "https://localhost:5001;http://localhost:5000"
答案 0 :(得分:1)
错误消息很明显:您的计算机上的某些内容已经在端口5000上侦听。
2个解决方案:
答案 1 :(得分:1)
出人意料地(或不出所料)我重新启动了我的电脑,然后没有错误:| 我检查了端口,但没有应用程序使用端口 5000,我不知道是什么导致了该错误
更新:
重新启动此服务可能会解决此问题:Windows 服务程序上的主机网络服务