One of the main issues that comes up over and over again for Cassandra is:
How do I run Cassandra as a Windows Service?
In this post I am going to answer that question and in the process demonstrate how to do it in less than 10 minutes.
Background
Cassandra is mainly developed by Linux developers so very little attention has been paid to the Windows developer or administrator as far as Cassandra goes. So as Windows developers we have to hop through a couple more hoops than just clicking on an install.exe file and and letting it do all the work. However lucky for us, those hoops are easy and quickly hopped through.
Step 1
If you haven’t done so already please read my jump start for Windows users on install Cassandra, this guide will get you ready for the next steps.
Step 2
The second step is also an easy one, you need to download a package called RunAsService, which provides the ability to run any program as a Windows Service.
After you have downloaded the file extract the contents to a directory of your choosing. (I extracted it to c:\RunAsService)
Note: RunAsService was originally developed here, however I recompiled it to run on .NET 2.0.
Step 3
To install RunAsService open up a command prompt with Administrative privileges and run this command.
cd c:\RunAsService install networkservice
This registers RunAsService with your Windows Service. Make sure to keep your command prompt open because you will need it for the 5th step.
Step 4
To configure RunAsService for Cassandra open up the RunAsService.exe.config file in your favorite text editor and replace <service.settings> section with the following so that it looks like this:
<!-- Services configuration -->
<service.settings>
<!-- Run Cassandra as a service -->
<!-- My Cassandra install path is C:\apache-cassandra\ -->
<service>
<name>Cassandra Database</name>
<executable>C:\apache-cassandra\bin\cassandra.bat</executable>
<parameters></parameters>
</service>
</service.settings>
After you have finished, save the config file and exit your text editor.
Note: My Cassandra install is in c:\apache-cassandra\ you will have to correct the config above for where you installed it if different than mine.
Step 5
The last and final step of this process is to start the RunAsService service. You can either do it through the Services control panel or just type the following in to your command prompt.
net start runasservice
You should see a response in the command line saying that the service has been successfully started. To verify that Cassandra has been started you can use the cassandra-cli.bat file:
cd c:\apache-cassandra\bin\ cassandra-cli.bat connect localhost/9160
It should report that it is connected to the server if the service is running. And with that we are done, and I told you it would only take about 10 minutes.
Cassandra, Windows Service

Hi -
Thanks for this. I got stuck at Step 3 through.
The zip that you’ve given to download doesn’t have the install.cmd at the top level.
I eventually copied it from SetupRunAsService into RunAsService/bin/Release, where it ran OK, and it looked like the network service was running with the config you describe, but then when I tried to connect I got
Exception connecting to localhost/9160 – java.net.ConnectException: Connection r
efused: connect
Maybe this is a problem with my Cassandra config though and not related to setting up RunAsService?
Your other article on ‘Jump Start for Windows’ was very helpful by the way… thanks.
Mark
Hi Mark,
I have been working on laying out the RunAsService project a little better. It was an old .NET 1.1 project that I have been updating. See if the new version is a better fit.
As for your error. It doesn’t sound like Cassandra is running. If all else fails, uninstall the service and then reinstall using the above steps.
Nick
Hi
Very helpful article, thank you and
Can you compare fluentcassandra with cassandraemon
In which conditions we have to choose one over other, is one them hava a coding superiority, etc…
If fluentcassandra is better, is there some functionality or better code parts that can be taken from cassandraemon ?
thanks
sirmak
Not the best person to reply on that. I developed Fluent Cassandra.
I’m working with Cassandra in .NET Framework and I created a .NET framework called “Aquiles” that have some improvements from using Thrift code directly. Take a look at it. Any feedback will be appreciated.
Hi Javier,
FluentCassadra uses the Thrift API directly too. I believe it is a basic requirement for talking to the Cassandra server. Not quite sure though what you mean by “improvements from using Thrift code directly”. Please explain.
Nick
First, HUGE thanks for this! Very helpful!
What did you do to address shutdown of the java process? Mine never goes away when stopping the service (presumably since the java process gets started as a seperate process).
Also, I had to modify the source for RunAsService to pass in the working directory from the config (since I don’t have CASSANDRA_HOME set) so that I could run it from the cassandra\bin directory.
Note for users of this: I found it helpful to get the stderr and stdout messages from cassandra, which you can do by putting ” > cassandra.log 2>&1″ into the parameters element.
Whoops! Looks like my xml-friendly string got smashed when I posted it. That string for stderr and stdout should by xml-ified with the standard substitutions.
To be honest, I have never had good luck with running Cassandra in windows. I had to actually setup a Linux box running Cassandra for my production environment. The Java as a service method never really has worked correctly in Windows. But I do use this for my dev environment.
But to directly answer your question, I reboot my box to get rid of the Java process.
Ok, I’ve changed the code to just find the java process by parent pid and kill it. Thanks again!
Good article.
However, I see that there is Apache provided method, to run cassandra as a service.
http://svn.apache.org/repos/asf/cassandra/trunk/README.txt