Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

nodetool stopdaemon

Stops the Cassandra daemon process.


Terminal window
nodetool [connection_options] stopdaemon

See connection options for connection options.

nodetool stopdaemon sends a shutdown signal to the Cassandra process, terminating the daemon. This is a hard stop that does not perform graceful draining—use drain first for a clean shutdown.

Not Graceful

stopdaemon does not flush memtables or complete pending operations. For graceful shutdown, always run drain before stopdaemon.


When stopdaemon is executed:

  1. JMX shutdown signal is sent to Cassandra
  2. Cassandra process begins termination
  3. In-flight requests may be interrupted
  4. Unflushed memtable data remains in commit log
  5. Process exits

What does NOT happen:

  • Memtables are not flushed to SSTables
  • Pending operations are not completed
  • Gossip shutdown notification is not sent
  • Other nodes are not informed gracefully

Terminal window
nodetool stopdaemon
Terminal window
# First drain (graceful)
nodetool drain
# Then stop
nodetool stopdaemon

When immediate shutdown is required:

Terminal window
nodetool stopdaemon

The recommended shutdown sequence:

Terminal window
# 1. Drain first (flushes data, stops accepting requests)
nodetool drain
# 2. Stop the daemon
nodetool stopdaemon

When immediate shutdown is critical:

Terminal window
# Stop immediately (not graceful)
nodetool stopdaemon

Use emergency stop when:

  • Node is causing cluster-wide issues
  • Runaway process consuming resources
  • Security incident requiring immediate isolation
  • drain is hanging or not responding

Once drain finishes, stopdaemon simply terminates the process:

Terminal window
# Drain completes
nodetool drain
# INFO: DRAINED
# Safe to stop now
nodetool stopdaemon

Actiondrainstopdaemon
Flush memtablesYesNo
Complete pending requestsYesNo
Stop gossipYesImmediate
Stop native transportYesImmediate
Notify other nodesYesNo
Process exitsNoYes
Data safetySafeRequires commit log replay
StepCommandWhat Happens
1drainFlush memtables, stop accepting requests, stop gossip
2stopdaemonExit process (data is safe)
StepCommandWhat Happens
1stopdaemonImmediate exit (commit log replay needed on restart)

Terminal window
# Check for Cassandra process
pgrep -f CassandraDaemon
# Should return nothing (no output)
# Alternative
ps aux | grep CassandraDaemon | grep -v grep
# Should return nothing
Terminal window
# CQL port
netstat -tlnp | grep 9042
# Should return nothing
# JMX port
netstat -tlnp | grep 7199
# Should return nothing
# Inter-node port
netstat -tlnp | grep 7000
# Should return nothing
verify_stopped.sh
#!/bin/bash
echo "=== Cassandra Stop Verification ==="
echo ""
# Process check
pid=$(pgrep -f CassandraDaemon)
if [ -z "$pid" ]; then
echo "Process: STOPPED"
else
echo "Process: STILL RUNNING (PID: $pid)"
fi
# Port checks
for port in 9042 7199 7000 7001; do
if netstat -tlnp 2>/dev/null | grep -q ":$port "; then
echo "Port $port: IN USE"
else
echo "Port $port: FREE"
fi
done

Terminal window
# Stop via systemd (usually runs drain internally)
systemctl stop cassandra

Most distribution packages configure systemd to call drain before stopping.

Terminal window
service cassandra stop
Terminal window
# Find PID
pid=$(pgrep -f CassandraDaemon)
# Normal kill (SIGTERM)
kill $pid
# Force kill if unresponsive (SIGKILL)
kill -9 $pid

Force Kill

kill -9 should only be used when the process is completely unresponsive. It prevents any cleanup and may require longer commit log replay.

MethodGracefulRuns DrainRecommended
nodetool drain && stopdaemonYesYesYes
systemctl stop cassandraUsuallyDepends on unit fileYes
nodetool stopdaemon aloneNoNoEmergency only
kill <pid>PartialNoLast resort
kill -9 <pid>NoNoExtreme emergency

graceful_stop.sh
#!/bin/bash
echo "=== Graceful Cassandra Shutdown ==="
echo ""
# 1. Check current state
echo "1. Pre-stop status:"
echo " Binary: $(nodetool statusbinary)"
echo " Gossip: $(nodetool statusgossip)"
# 2. Drain
echo ""
echo "2. Draining node..."
nodetool drain
echo " Drain complete"
# 3. Stop daemon
echo ""
echo "3. Stopping daemon..."
nodetool stopdaemon
# 4. Wait for process exit
echo ""
echo "4. Waiting for process to exit..."
for i in {1..30}; do
if ! pgrep -f CassandraDaemon > /dev/null; then
echo " Process stopped"
break
fi
sleep 1
done
# 5. Verify
echo ""
echo "5. Verification:"
if pgrep -f CassandraDaemon > /dev/null; then
echo " WARNING: Process still running!"
else
echo " Cassandra stopped successfully"
fi

emergency_stop.sh
#!/bin/bash
echo "=== EMERGENCY STOP ==="
echo "WARNING: This is not a graceful shutdown!"
echo ""
# Immediate stop
nodetool stopdaemon
# Wait briefly
sleep 5
# Check if stopped
if pgrep -f CassandraDaemon > /dev/null; then
echo "Process still running, forcing kill..."
pkill -9 -f CassandraDaemon
sleep 2
fi
# Final check
if pgrep -f CassandraDaemon > /dev/null; then
echo "ERROR: Cannot stop Cassandra!"
exit 1
else
echo "Cassandra stopped"
echo "NOTE: Commit log replay will occur on restart"
fi

When Cassandra restarts after stopdaemon without drain:

  1. Commit log is replayed
  2. Unflushed memtable data is recovered
  3. Startup may take longer
  4. Data integrity is maintained (commit log is durable)
Terminal window
# Start after emergency stop
systemctl start cassandra
# Monitor startup (may be slower due to replay)
tail -f /var/log/cassandra/system.log | grep -i "replay\|starting\|listening"

Clean restart:

Terminal window
# Normal start
systemctl start cassandra
# Quick startup expected
tail -f /var/log/cassandra/system.log | grep -i "starting\|listening"

If JMX command fails:

Terminal window
# Check JMX connectivity
nodetool info
# If this fails, JMX is unreachable
# Use kill instead
pid=$(pgrep -f CassandraDaemon)
kill $pid

If process doesn't exit:

Terminal window
# Check process state
ps aux | grep CassandraDaemon
# Check what it's doing
strace -p $(pgrep -f CassandraDaemon) 2>&1 | head -20
# Force kill if necessary
kill -9 $(pgrep -f CassandraDaemon)
Terminal window
# If nodetool can't connect
nodetool stopdaemon
# Error: Failed to connect to '127.0.0.1:7199'
# Use systemctl or kill instead
systemctl stop cassandra
# or
kill $(pgrep -f CassandraDaemon)

Shutdown Guidelines

  1. Always drain first - Run nodetool drain before stopdaemon
  2. Use systemd in production - Prefer systemctl stop for managed shutdown
  3. Verify stopped - Confirm process exited and ports released
  4. Document emergency stops - Log when and why emergency stop was used
  5. Allow startup time - Expect longer restart after non-graceful stop
  6. Reserve for emergencies - Only use stopdaemon alone when drain is not viable

CommandRelationship
drainGraceful prepare for shutdown
statusCheck cluster status before stop
infoNode information
disablebinaryStop client connections
disablegossipStop cluster communication