apache/cassandra · error · IllegalArgumentException
Cannot combine -dc and -hosts options.
Error message
Cannot combine -dc and -hosts options.
What it means
RepairOption.parse rejects repair requests that specify both datacenter and host restrictions. A repair is scoped either by datacenters or by explicit hosts, never both, so supplying both -dc and -hosts is treated as a contradictory request. IllegalArgumentException is thrown before the repair starts.
Source
Thrown at src/java/org/apache/cassandra/repair/messages/RepairOption.java:287
if (cfStr != null)
{
Collection<String> columnFamilies = new HashSet<>();
StringTokenizer tokenizer = new StringTokenizer(cfStr, ",");
while (tokenizer.hasMoreTokens())
{
columnFamilies.add(tokenizer.nextToken().trim());
}
option.getColumnFamilies().addAll(columnFamilies);
}
// validate options
if (jobThreads > MAX_JOB_THREADS)
{
throw new IllegalArgumentException("Too many job threads. Max is " + MAX_JOB_THREADS);
}
if (!dataCenters.isEmpty() && !hosts.isEmpty())
{
throw new IllegalArgumentException("Cannot combine -dc and -hosts options.");
}
if (primaryRange && ((!dataCenters.isEmpty() && !option.isInLocalDCOnly()) || !hosts.isEmpty()))
{
throw new IllegalArgumentException("You need to run primary range repair on all nodes in the cluster.");
}
if (pullRepair)
{
if (hosts.size() != 2)
{
throw new IllegalArgumentException("Pull repair can only be performed between two hosts. Please specify two hosts, one of which must be this host.");
}
else if (ranges.isEmpty())
{
throw new IllegalArgumentException("Token ranges must be specified when performing pull repair. Please specify at least one token range which both hosts have in common.");
}
}
return option;View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Use only -hosts when targeting specific nodes
- Use only -dc when scoping the repair to whole datacenters
- Remove one of the two flags in your script/config
Example fix
// before nodetool repair -dc dc1 -hosts 10.0.0.1 keyspace1 // after nodetool repair -dc dc1 keyspace1
Defensive patterns
Strategy: validation
Validate before calling
if (dcList != null && !dcList.isEmpty() && hostList != null && !hostList.isEmpty())
throw new IllegalArgumentException("Specify either -dc or -hosts for repair, not both"); Try / catch
try { RepairOption.parse(opts); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Cannot combine -dc and -hosts")) { /* drop one scope and re-invoke */ } else throw e; } Prevention
- Let repair scripts accept a single 'scope' parameter that maps to either -dc or -hosts
- Audit shared repair scripts for accumulated flags
- Document scoping semantics in runbooks
When it happens
Trigger: nodetool repair -dc dc1 -hosts 127.0.0.1 (or RepairOption.parse with options containing both DATACENTERS and HOSTS entries non-empty).
Common situations: Scripts accumulated flags over time; operators combining a DC filter with a specific endpoint to 'narrow further'; copy-paste from two different runbooks.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- You need to run primary range repair on all nodes in the clu
- Cannot specify a repair as both paxos only and accord only
- Too many job threads. Max is %s
- Pull repair can only be performed between two hosts. Please
- Token ranges must be specified when performing pull repair.
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/c3d9faa1c9eff194.
Report an issue: GitHub.