apache/cassandra · error · UnsupportedOperationException

Host ID not found.

Error message

Host ID not found.

What it means

removeNode looks up the endpoint for the given host ID in the cluster metadata directory; when no node with that NodeId exists, it throws UnsupportedOperationException("Host ID not found."). The cluster has no record of the supplied identifier.

Solutions

  1. Run `nodetool status` on any live node and copy the exact Host ID of the target, then retry.
  2. Confirm you are pointing at the right cluster/contact points.
  3. If the node was already removed, no action is needed — the ID is simply gone.
  4. Strip stray whitespace or quotes from the host ID argument.

Example fix

// before
nodetool removenode 8f3e-...  // stale id
// after
String hostId = getHostIdFromNodetoolStatus(deadNodeIp); // look up fresh
nodetool.removenode(hostId);
Defensive patterns

Strategy: validation

Validate before calling

String hostId = getTargetHostId();
Set<String> known = storageService.getHostIdMap().keySet(); // live view of registered ids
if (!known.contains(hostId))
    throw new IllegalArgumentException("Host ID " + hostId + " not registered in this cluster");

Try / catch

try {
    storageService.removeNode(hostId);
} catch (UnsupportedOperationException e) {
    if (e.getMessage().equals("Host ID not found.")) {
        String fresh = lookupHostIdFromNodetoolStatus();
        if (fresh != null) storageService.removeNode(fresh);
    } else throw e;
}

Prevention

When it happens

Trigger: Calling `nodetool removenode <hostId>` with a host ID absent from ClusterMetadata.directory — typo, removed-already node, or an ID from a different cluster.

Common situations: Stale runbook references to a node that was already removed; mistyped or truncated UUID; copying a host ID from the wrong cluster in a multi-cluster environment; trailing whitespace/quotes in the argument.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/972437777fc599ba. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/tcm/sequences/SingleNodeSequences.java:134

    {
        abortHelper(nodeId, MultiStepOperation.Kind.LEAVE, DECOMMISSION_FAILED);
    }

    /**
     * Entrypoint to begin node removal process
     *
     * @param toRemove id of the node to remove
     * @param force if set to true, will remove the node even if this would mean there will be not enough nodes
     *              to satisfy replication factor
     */
    static void removeNode(NodeId toRemove, boolean force)
    {
        ClusterMetadata metadata = ClusterMetadata.current();
        if (toRemove.equals(metadata.myNodeId()))
            throw new UnsupportedOperationException("Cannot remove self");
        InetAddressAndPort endpoint = metadata.directory.endpoint(toRemove);
        if (endpoint == null)
            throw new UnsupportedOperationException("Host ID not found.");
        if (Gossiper.instance.getLiveMembers().contains(endpoint))
            throw new UnsupportedOperationException("Node " + endpoint + " is alive and owns this ID. Use decommission command to remove it from the ring");

        NodeState removeState = metadata.directory.peerState(toRemove);
        if (removeState == null)
            throw new UnsupportedOperationException("Node to be removed is not a member of the token ring");
        if (removeState == NodeState.LEAVING)
            logger.warn("Node {} is already leaving or being removed, continuing removal anyway", endpoint);

        if (metadata.inProgressSequences.contains(toRemove))
            throw new UnsupportedOperationException("Can not remove a node that has an in-progress sequence");

        ReconfigureCMS.maybeReconfigureCMS(metadata, endpoint);

        logger.info("starting removenode with {} {}", metadata.epoch, toRemove);
        Collection<Token> tokens  = metadata.tokenMap.tokens(toRemove);
        ClusterMetadataService.instance().commit(new PrepareLeave(toRemove,
                                                                  force,

View on GitHub (pinned to 88fd0f6a0e)