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.
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