PortInUseException - After Running as Administrator


Windows 10:

I was getting a Bad Header Request Error 400 after a new install of Sonarr. I found an article that said to launch with Run As Administrator to resolve this. I did, and it fixed that issue, however I then needed to make a change that required a restart of the service.

When I did, I got the above error PortInUseException. Port 8989 is already in use.

I did a netstat and saw that the port was allocated to Internet explorer. So I killed all instances of IE and tried again, same error.

I edited the config file directly for Sonarr to a different port, ran it again and it came back with the same port exception (on the new port), so it appears to be making it’s own port exception.

Tried re-installing, same issue. When it’s running in Administrator, it can’t see my network drives which hold my data.

Any ideas on how to stop it thinking the port is in use, when it’s launching it itself?

Log details below:

18-8-6 21:52:35.7|Info|Bootstrap|Starting Sonarr - C:\ProgramData\NzbDrone\bin\NzbDrone.exe - Version
18-8-6 21:52:36.6|Info|Router|Application mode: Interactive
18-8-6 21:52:36.9|Info|MigrationLogger|*** Migrating data source=C:\ProgramData\NzbDrone\nzbdrone.db;cache size=-10485760;datetimekind=Utc;journal mode=Wal;pooling=True;version=3 ***
18-8-6 21:52:37.4|Info|MigrationLogger|*** Migrating data source=C:\ProgramData\NzbDrone\logs.db;cache size=-10485760;datetimekind=Utc;journal mode=Wal;pooling=True;version=3 ***
18-8-6 21:52:37.6|Info|OwinHostController|Listening on the following URLs:
18-8-6 21:52:37.6|Info|OwinHostController|
18-8-6 21:52:37.6|Info|OwinHostController| http://localhost:8989/
18-8-6 21:52:38.0|Info|NancyBootstrapper|Starting Web Server
18-8-6 21:52:40.3|Fatal|WindowsApp|EPIC FAIL

[v2.0.0.5228] NzbDrone.Host.Owin.PortInUseException: Port 8989 is already in use, please ensure NzbDrone is not already running. —> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Net.HttpListenerException: Access is denied
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func2 appFunc, IList1 addresses, IDictionary2 capabilities, Func2 loggerFactory)
at Microsoft.Owin.Host.HttpListener.OwinServerFactory.Create(Func2 app, IDictionary2 properties)
— End of inner exception stack trace —
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder)
at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context)
at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context)
at NzbDrone.Host.Owin.OwinAppFactory.CreateApp(List1 urls) in C:\BuildAgent\work\5d7581516c0ee5b3\src\NzbDrone.Host\Owin\OwinServiceProvider.cs:line 52 --- End of inner exception stack trace --- at NzbDrone.Host.Owin.OwinAppFactory.CreateApp(List1 urls) in C:\BuildAgent\work\5d7581516c0ee5b3\src\NzbDrone.Host\Owin\OwinServiceProvider.cs:line 63
at NzbDrone.Host.Owin.OwinHostController.StartServer() in C:\BuildAgent\work\5d7581516c0ee5b3\src\NzbDrone.Host\Owin\OwinHostController.cs:line 53
at NzbDrone.Host.NzbDroneServiceFactory.Start() in C:\BuildAgent\work\5d7581516c0ee5b3\src\NzbDrone.Host\ApplicationServer.cs:line 61
at NzbDrone.Host.Router.Route(ApplicationModes applicationModes) in C:\BuildAgent\work\5d7581516c0ee5b3\src\NzbDrone.Host\Router.cs:line 47
at NzbDrone.Host.Bootstrap.Start(ApplicationModes applicationModes, StartupContext startupContext) in C:\BuildAgent\work\5d7581516c0ee5b3\src\NzbDrone.Host\Bootstrap.cs:line 78
at NzbDrone.Host.Bootstrap.Start(StartupContext startupContext, IUserAlert userAlert, Action`1 startCallback) in C:\BuildAgent\work\5d7581516c0ee5b3\src\NzbDrone.Host\Bootstrap.cs:line 41
at NzbDrone.WindowsApp.Main(String[] args) in C:\BuildAgent\work\5d7581516c0ee5b3\src\NzbDrone\WindowsApp.cs:line 23


Is that the IP of the system running Sonarr?
Do you get the same error if you change the BindAddress in the config file to it’s default of *?


Yep. Tried that. Doesn’t matter what I set it to (another port, specific IP, * etc) I’d get the same error after doing a run once as administrator. If I run again as administrator it’s fine, but can’t see mapped drives.

I’ve fixed it (kind of), by reinstalling, running as a service, changing the service to run as a local account and then changing all the top level folders to be UNC path names rather than the mapped drive letter. Back up and running with remote access.


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.