apache/cassandra · error · IllegalStateException
Missing host
Error message
Missing host
What it means
Thrown by Server.getSocket() when a port was provided but no host address was set, so the builder cannot construct the bind InetSocketAddress. Like the missing-port case, it surfaces as an IllegalStateException at server start rather than at builder time, indicating incomplete server configuration.
Solutions
- Call Server.Builder.host(InetAddress) (or equivalent) with the address to bind, e.g. the local RPC address
- Or supply a full InetSocketAddress via the socket(...) builder method
- Use InetAddress.getLoopbackAddress() in test harnesses if binding to all interfaces is not intended
- Validate builder fields before start() in embedding code
Example fix
// before Server.builder().withPort(9042).build(); // after Server.builder().withPort(9042).withHost(InetAddress.getLocalHost()).build();
Defensive patterns
Strategy: validation
Validate before calling
if (builderHost == null) throw new IllegalArgumentException("Server.Builder requires a host; call host(...) or socket(...)"); Type guard
boolean readyToBuild(Server.Builder b) { return b.getHostAddr() != null && b.getPort() != -1; } Try / catch
try { server.start(); } catch (IllegalStateException e) { if (e.getMessage().equals("Missing host")) { fixBuilderConfig(); } else throw e; } Prevention
- Set host and port together in one helper to avoid partial configuration
- Default to the RPC address from config rather than leaving host null
- Cover server construction with a smoke test
- Validate builder completeness before start()
When it happens
Trigger: Server.Builder built with port(...) but no hostAddr and no explicit socket; getSocket() reaches the else branch because this.hostAddr is null while this.port != -1.
Common situations: Embedding the transport in tests/tools with only a port configured, refactoring away a host constant, or assuming the server will default to binding all interfaces (it will not here).
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Missing port number
- be positive
- native_transport_min_backoff_on_queue_overload should be…
- a hints file cannot be configured for both compression and…
- A maximum number of tokens per node is supported
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/89c08d744d5ae0ed.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/transport/Server.java:292
}
public Server build()
{
return new Server(this);
}
private InetSocketAddress getSocket()
{
if (this.socket != null)
return this.socket;
else
{
if (this.port == -1)
throw new IllegalStateException("Missing port number");
if (this.hostAddr != null)
this.socket = new InetSocketAddress(this.hostAddr, this.port);
else
throw new IllegalStateException("Missing host");
return this.socket;
}
}
}
public static class ConnectionTracker implements Connection.Tracker
{
private static final ChannelMatcher PRE_V5_CHANNEL = channel -> channel.attr(Connection.attributeKey)
.get()
.getVersion()
.isSmallerThan(ProtocolVersion.V5);
// TODO: should we be using the GlobalEventExecutor or defining our own?
public final ChannelGroup allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
private final EnumMap<Event.Type, ChannelGroup> groups = new EnumMap<>(Event.Type.class);
private final ProtocolVersionTracker protocolVersionTracker = new ProtocolVersionTracker();
private final BooleanSupplier isRunning;
View on GitHub (pinned to 88fd0f6a0e)