Windows service - Error 5: Access is denied


I am deploying a C# windows service hosted with TopShelf and the service is getting installed just fine. I cannot start it though, I get “Error 5: Access is denied.” Can you help?


Hi Adam,

Thanks for getting in touch! Sometimes this occurs when the Service name doesn’t match the service. Of course there can be a few reasons that this occurs.
Can you provide us with a screenshot of your step’s configuration, and also the TopShelf configuration code so we might be able to figure out why this service won’t start.


Hello Vanessa, and thanks for the reply. I’m actually using powershell scripts to deploy using the built in TopShelf commands (uninstall, install). Would you suggest I use the windows service deployment built in? When I tried that, the service started and immediately stopped.

Hi Adam,

Your own PowerShell is fine, it sort of helps eliminate some issues really.
So a few questions. Were you ever able to get a deployment done manually using your powershell process without Octopus ? Ie just running the scripts on the box.
We were able to find a couple of threads on why you would get that error on the service:

I wonder if they would help you to trouble shoot a naming, or permissions error, and if they do we can help you find a resolution such as maybe needing to use a different user on the Tentacle service.


Thanks Vanessa,

This turned out to be unrelated to permissions - the app.config had an invalid reference but for some reason that error was raised.