NzbDrone thinks interface is bound already

So I did a ‘service nzbdrone restart’ (running Ubuntu 14.04) of nzbdrone while making some configuration changes, nzbdrone restarted, the process was running, but I noticed that nothing was listening on the bound port.

I checked the log file and found the following repeating:

nzbdrone start/running, process 16756
14-7-23 15:49:27.0|Info|Bootstrap|Starting NzbDrone - /opt/NzbDrone/NzbDrone.exe - Version 2.0.0.1632
14-7-23 15:49:28.0|Info|MigrationLogger|*** Migrating data source=/home/media/.config/NzbDrone/nzbdrone.db;cache size=-10485760;datetimekind=Utc;journal mode=Wal ***
14-7-23 15:49:28.2|Info|MigrationLogger|*** Migrating data source=/home/media/.config/NzbDrone/logs.db;cache size=-10485760;datetimekind=Utc;journal mode=Wal ***
14-7-23 15:49:28.3|Info|Router|Application mode: Interactive
14-7-23 15:49:28.3|Info|OwinHostController|Listening on the following URLs:
14-7-23 15:49:28.3|Info|OwinHostController|  http://*:8989//
14-7-23 15:49:28.3|Info|OwinHostController|  http://*:8989/
14-7-23 15:49:28.5|Info|NancyBootstrapper|Starting NzbDrone API
14-7-23 15:49:32.1|Info|HousekeepingService|Running housecleaning tasks
14-7-23 15:49:32.2|Info|DownloadDecisionMaker|Processing 3 reports
14-7-23 15:49:33.2|Info|MissingEpisodeSearchService|Episode search completed. 0 reports downloaded.
14-7-23 15:49:33.4|Fatal|ConsoleApp|EPIC FAIL!

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: Prefix already in use.
  at System.Net.EndPointListener.AddSpecial (System.Collections.ArrayList coll, System.Net.ListenerPrefix prefix) [0x00000] in <filename unknown>:0
  at System.Net.EndPointListener.AddPrefix (System.Net.ListenerPrefix prefix, System.Net.HttpListener listener) [0x00000] in <filename unknown>:0
  at System.Net.EndPointManager.AddPrefixInternal (System.String p, System.Net.HttpListener listener) [0x00000] in <filename unknown>:0
  at System.Net.EndPointManager.AddListener (System.Net.HttpListener listener) [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
  at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create (IAppBuilder builder) [0x00000] in <filename unknown>:0
  at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer (Microsoft.Owin.Hosting.Engine.StartContext context) [0x00000] in <filename unknown>:0
  at Microsoft.Owin.Hosting.Engine.HostingEngine.Start (Microsoft.Owin.Hosting.Engine.StartContext context) [0x00000] in <filename unknown>:0
  at Microsoft.Owin.Hosting.WebApp.StartImplementation (IServiceProvider services, Microsoft.Owin.Hosting.StartOptions options, System.Action`1 startup) [0x00000] in <filename unknown>:0
  at Microsoft.Owin.Hosting.WebApp.Start (IServiceProvider services, Microsoft.Owin.Hosting.StartOptions options, System.Action`1 startup) [0x00000] in <filename unknown>:0
  at NzbDrone.Host.Owin.OwinHostController.StartServer () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at NzbDrone.Host.Owin.OwinHostController.StartServer () [0x00000] in <filename unknown>:0
  at NzbDrone.Host.NzbDroneServiceFactory.Start () [0x00000] in <filename unknown>:0
  at NzbDrone.Host.Router.Route (ApplicationModes applicationModes) [0x00000] in <filename unknown>:0
  at NzbDrone.Host.Bootstrap.Start (ApplicationModes applicationModes, NzbDrone.Common.EnvironmentInfo.StartupContext startupContext) [0x00000] in <filename unknown>:0
  at NzbDrone.Host.Bootstrap.Start (NzbDrone.Common.EnvironmentInfo.StartupContext startupContext, IUserAlert userAlert, System.Action`1 startCallback) [0x00000] in <filename unknown>:0
  at NzbDrone.Console.ConsoleApp.Main (System.String[] args) [0x00000] in <filename unknown>:0

I use the templated init script found in the wiki:

author "Simon Tallmyr - Nosscire"
description "Upstart Script to run NzbDrone as a service on Ubuntu/Debian based systems, as well as others"

#Set username for the process. Should probably be what you use for logging in
setuid media

#This is the install directory. If you installed using a deb package or the NzbDrone Repository you do not need to change this
env DIR=/opt/NzbDrone

setgid nogroup
start on runlevel [2345]
stop on runlevel [016]

respawn

exec mono $DIR/NzbDrone.exe

I can also confirm that NOTHING is listening or bound to port 8989 on any interface on the server, as evidenced by a netstat -ntpl.

Now what’s really weird, is if I try to manually execute it as a user that’s NOT the ‘media’ user (any other user, root or another non-privileged user for example) I have this set up to run as, it starts up just fine without any issue what so ever.

I noticed the following in the logs (I was attempting to get this set up for reverse proxy and suspect that’s the damage):

14-7-23 15:49:28.3|Info|OwinHostController|  http://*:8989//
14-7-23 15:49:28.3|Info|OwinHostController|  http://*:8989/

Unfortunately I’ve found no way to manually edit any configuration anywhere that would let me correct what I can only assume is causing the issue here and the reverse proxy is somehow trying to bind a separate instance to the same port.

I’ve even attempted to do a select * from each of the tables in the nzbdrone.db sqlite database and not managed to find anywhere in there where the proxy setting is toggled.

At this point I can only assume that this setting is in one of the mdb access database files and the mdb-tools suite doesn’t seem to be capable of doing anything with those.

Have I pretty much found myself backed into a corner whereby my only option is to fully set nzbdrone back up again? I’m really hoping not :expressionless:

Or I’m a complete idiot and couldn’t see the forest from the trees and that the line that was causing all my problems was staring me right in the face in the config.xml file the whole time:

  <UrlBase>
  </UrlBase>

Was set to

  <UrlBase>/
  </UrlBase>

Got rid of that erroneous / and problem solved.

Yeah, thats it. drone should handle that better though, I’ll take a look at try to improve it.