错误-98 EADDRINUSE地址已在Ubuntu上使用

错误-98 EADDRINUSE地址已在Ubuntu上使用,ubuntu,asp.net-core,.net-core,Ubuntu,Asp.net Core,.net Core,我刚刚创建了一个简单的.NET核心webapi项目,使用 然后尝试在Ubuntu子系统上运行应用程序 当我运行dotnet start时,我收到一个错误: Unhandled Exception: System.AggregateException: One or more errors occurred. (Error -98 EADDRINUSE address already in use) ---> Microsoft.AspNetCore.Server.Kestrel.Inter

我刚刚创建了一个简单的.NET核心webapi项目,使用

然后尝试在Ubuntu子系统上运行应用程序

当我运行
dotnet start
时,我收到一个错误:

Unhandled Exception: System.AggregateException: One or more errors occurred. (Error -98 EADDRINUSE address already in use) ---> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -98 EADDRINUSE address already in use
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.Check(Int32 statusCode)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.GetSockIPEndPoint()
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListenerPrimary.CreateListenSocket()
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<>c.<StartAsync>b__6_0(Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.ListenerPrimary.<StartAsync>d__11.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.CreateServer(ServerAddress address)
   at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication1 application)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token, String shutdownMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at WebApp.Program.Main(String[] args)
所以现在它工作得很好。但是,我没有更改端口值。
你有没有想过为什么端口
5000
在未指定的情况下无法在Ubuntu中工作?

你使用的是哪个端口?您的Linux上的另一个应用程序是否使用该端口?@Tseng,刚刚更新了我的问题。http://*:5000允许从任何接口使用任何IP4和IP6地址,因此尽管它仍然使用5000端口,但另一个地址可能会被使用。是的。我曾经有过类似的问题,但我认为已经解决了。但我在Azure应用程序服务上使用了它,因为它正试图绑定到IPv4和IPv6。您是否尝试绑定到
http://0.0.0.0:5000
而不是http://*:5000?GitHub问题和相关问题最后但并非最不重要的一点是,您可以遵循最后一条评论:并尝试将
useisintegration()
放在
UseUrls
之后,像这样
UseUrls(“http://*:5000”)。useisintegration()
,除非您计划在IIS上托管它,否则您也可以完全删除它
var host = new WebHostBuilder()
                .UseConfiguration(config)
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .UseUrls("http://*:5000")
                .Build();