Summary: it works as dotnet run
, but it doesn't work as dotnet myappname.dll
.
My linux skills are limited, but I am trying to go by the book so I don't mix things up (following this tutorial from Scott Hanselman):
$ cd /home/myusername/dotnettest
$ dotnet run
Now listening on: http://localhost:5123
Then I move it to /var like so:
$ sudo cp -a /home/myusername/dotnettest/bin/Debug/netcoreapp1.1/publish /var/dotnettest
Finally I test if it works there as well:
$ dotnet dotnettest.dll
Then it fails:
info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0]
User profile is available. Using '/home/myusername/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
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.TcpListener.CreateListenSocket()
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<>c.<StartAsync>b__6_0(Object state)
--- 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](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) in /home/myusername/dotnettest/Program.cs:line 27
Aborted (core dumped)
I've been careful in trying to stop nginx.
I've checked if anything is listening to :5123 with the command:
$ lsof -i tcp:5123
And nothing seems to come up.
When launching the app from a command prompt in the project's folder, dotnet run launches the app and server (Kestrel and HTTP. sys only). The configuration is specified by the -c|--configuration option, which is set to either Debug (default) or Release . A launchSettings.
It require https certificate to run. There are two ways to fix the issue . 2- Switching back to Kestrel and changing the port number in the applicationUrl setting in the launchSettings. json file fixed the issue.
Net applications run on Kestrel servers and we run Apache or Nginx server in Linux environments, which acts as a proxy server and handles the traffic from outside the machine and redirects it to the Kestrel server so we will have Apache or Nginx server as the middle layer.
The following command help to find the port and kill the process
Terminal on mac
find the process number
lsof -i: <port number>
eg lsof -i:5001
Then kill the process number
kill -9 <process number>
eg - kill -9 1600
in linux/mac
ps aux | grep "dotnet"
Find the process and then run
kill -9 <process_id>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With