apache/cassandra · error · RuntimeException
java.net.UnknownHostException
Error message
java.net.UnknownHostException
What it means
getOwnershipByDcWithPort resolves endpoint IPs to hostnames (via resolveIp/DNS reverse lookup) while computing token ownership per datacenter, and any java.net.UnknownHostException is rethrown as a RuntimeException. It means DNS could not reverse-map one of the cluster member IPs.
Solutions
- Add the node IPs to /etc/hosts (or DNS PTR records) so reverse resolution succeeds.
- Fix the resolver configuration (resolv.conf) or VPN/DNS connectivity.
- Enable/verify `broadcast_address`/`listen_address` settings so ring IPs are resolvable.
- Report against the wrapped UnknownHostException cause to identify the failing IP.
Example fix
// before # /etc/hosts missing cluster node IPs // after 10.0.0.5 cassandra-1 10.0.0.6 cassandra-2 # add entries so reverse lookup succeeds
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-resolve each endpoint IP before requesting ownership InetAddress addr = InetAddress.getByName(ip); // throws UnknownHostException early, locally diagnosable
Try / catch
try { ownership = CommandUtils.getOwnershipByDcWithPort(probe, ...); }
catch (RuntimeException e) {
if (e.getCause() instanceof java.net.UnknownHostException uhe) { /* fix DNS/hosts, or fall back to IP display */ }
else throw e;
} Prevention
- Maintain /etc/hosts or DNS PTR records for all cluster node IPs.
- Verify DNS resolver health on the machine running nodetool.
- Prune stale IPs after node replacement/decommission.
- In cloud environments, prefer endpoints that support reverse DNS.
When it happens
Trigger: Running ownership-reporting commands (e.g. `nodetool tablehistograms`, `nodetool tpstats`-style ownership output, RingState/OwnershipCommands) where a node's IP has no PTR record or DNS is unreachable.
Common situations: Cloud environments without reverse DNS for instance IPs; /etc/hosts entries missing; broken or slow DNS resolvers; nodes recently replaced leaving stale IPs in ring metadata.
Related errors
- Unable to look up endpoint
- Could not assassinate an unresolvable endpoint
- Replacement host name could not be resolved or scope_id was…
- Unable to obtain private address for node from cloud…
- Unable to obtain public address for node from cloud…
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/715ec384d72d4de8.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/tools/nodetool/CommandUtils.java:250
public static SortedMap<String, SetHostStatWithPort> getOwnershipByDcWithPort(NodeProbe probe, boolean resolveIp,
Map<String, String> tokenToEndpoint,
Map<String, Float> ownerships)
{
SortedMap<String, SetHostStatWithPort> ownershipByDc = Maps.newTreeMap();
EndpointSnitchInfoMBean epSnitchInfo = probe.getEndpointSnitchInfoProxy();
try
{
for (Map.Entry<String, String> tokenAndEndPoint : tokenToEndpoint.entrySet())
{
String dc = epSnitchInfo.getDatacenter(tokenAndEndPoint.getValue());
if (!ownershipByDc.containsKey(dc))
ownershipByDc.put(dc, new SetHostStatWithPort(resolveIp));
ownershipByDc.get(dc).add(tokenAndEndPoint.getKey(), tokenAndEndPoint.getValue(), ownerships);
}
}
catch (UnknownHostException e)
{
throw new RuntimeException(e);
}
return ownershipByDc;
}
private enum KeyspaceSet
{
ALL, NON_SYSTEM, NON_LOCAL_STRATEGY, ACCORD_MANAGED
}
}
View on GitHub (pinned to 88fd0f6a0e)