Search code examples
windows-servicesravendbwindows-authentication

How do I run RavenDB as a service using an account other than Local System?


I am trying to install RavenDB to run as a Windows service. By default it sets itself up to run under the Local System account, so I am trying to mitigate security risks by running it under a dedicated account. I have already granted Full Access to the file system for both the program directory c:\Program Files\RavenDB and the data directory d:\Data\RavenDB. However, when I try to start the service it fails immediately and I get the following error in the event log:

RavenDB service failed to start because of an error
System.Net.HttpListenerException (0x80004005): Access is denied
   at System.Net.HttpListener.AddAllPrefixes()
   at System.Net.HttpListener.Start()
   at Raven.Database.Server.HttpServer.StartListening() in c:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs:line 350
   at Raven.Server.RavenDbServer..ctor(RavenConfiguration settings) in c:\Builds\RavenDB-Stable\Raven.Server\RavenDbServer.cs:line 43
   at Raven.Server.RavenService.<OnStart>b__0() in c:\Builds\RavenDB-Stable\Raven.Server\RavenService.cs:line 37

So, how do I configure a user to run RavenDB? What permissions do I need to grant? I've checked the RavenDB documentation and forums but didn't see this issue discussed anywhere.


Solution

  • I assume you are missing the url acl for your service account. Open a command prompt as administrator and enter the following

    netsh http add urlacl url=http://+:8080/ user=domain\user
    

    This should grant the necessary rights for your service account in order to create a HttpListener for this port