简体   繁体   English

Linux上的Asp.NET Core错误

[英]Error With Asp.NET Core on Linux

I'm trying to follow the steps here to get an ASP.net core running on Ubuntu 我正在尝试按照此处的步骤来在Ubuntu上运行ASP.net核心

https://docs.asp.net/en/latest/getting-started.html https://docs.asp.net/cn/latest/getting-started.html

I followed the steps to install .NET core and verified that is running ok. 我按照步骤安装.NET Core,并确认运行正常。

The ASP app builds without errors, but when I try to run the ASP app, 'dotnet run' the following exception is thrown: ASP应用程序的构建没有错误,但是当我尝试运行ASP应用程序时,“ dotnet run”会引发以下异常:

Unhandled Exception: System.AggregateException: One or more errors occurred. 未处理的异常:System.AggregateException:发生一个或多个错误。 (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.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.d__11.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at Sys (错误-98 EADDRINUSE地址已在使用中)---> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException:错误-98 EADDRINUSE地址已在Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv中使用Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.GetSockIPEndPoint()处的Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListenerPrimary.CreateListenSocket()处的.Check(Int32 statusCode) .Internal.Http.Listener。<> c.b__6_0(对象状态)-从上一个引发异常的位置开始的堆栈跟踪-在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)。 Microsoft.AspNetCore.Server.Kestrel.Internal.Http.ListenerPrimary.d__11.MoveNext()上的Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)---内部异常堆栈跟踪的结尾---在System.Threading.Tasks。 Sys上的Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) tem.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](IHttpApplication`1 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 WebApplication.Program.Main(String[] args) tem.Threading.Tasks.Task.Wait(Int32毫秒超时,CancellationToken cancelleToken)在Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.CreateServer(服务器地址)在Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start [TContext]( Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()上的IHttpApplication`1应用程序)Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost主机,CancellationToken令牌,字符串shutdownMessage)在Microsoft.AspNetCore.Hosting.Internal.WebHost.Start() IWebHost主机)位于WebApplication.Program.Main(String [] args)

I've searched around the webz for an a solution, but couldn't find anything. 我在webz上搜索了解决方案,但找不到任何东西。

Any ideas? 有任何想法吗?

Some other program on your system is already using the port the ASP.NET web server is trying to bind to (another dev web server, perhaps). 系统上的其他程序已经在使用ASP.NET Web服务器试图绑定到的端口(也许是另一台dev Web服务器)。 Use the command sudo netstat -ltp to find out what's listening and stop the servers that do, or alternatively, have the ASP.NET web server use another port, using one of the techniques described in the relevant issue on the ASP.NET github , eg by invoking dotnet run --server.urls http://0.0.0.0:1234 . 使用sudo netstat -ltp命令找出正在侦听的内容并停止正在运行的服务器,或者使用ASP.NET github上相关问题中所述的一种方法,使ASP.NET Web服务器使用另一个端口,例如,通过调用dotnet run --server.urls http://0.0.0.0:1234

Turns out, I had to add the .UseUrls("http://*:5000") setting to the Program.cs file. 原来,我必须将.UseUrls(“ http:// *:5000”)设置添加到Program.cs文件中。

Error -98 EADDRINUSE address already in use on Ubuntu 错误-98 EADDRINUSE地址已在Ubuntu上使用

Usually this error occurs due to closed the web site and terminated hosting irregularly (missed 'ctrl+c', instead probably with 'ctrl+z'); 通常,由于关闭网站并终止不定期托管而导致此错误(缺少“ ctrl + c”,而可能是“ ctrl + z”); However, the tcp:{port} still be listening, you've to terminate or kill the process manually by ' kill -9 pid ' 但是,tcp:{port}仍在监听,您必须通过' kill -9 pid '手动终止或终止该过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM