SonarSource/sonarqube · error · IllegalStateException
Can not resolve host [. Please check network settings and pr
Error message
Can not resolve host [. Please check network settings and property
What it means
resolveAddress converts a configured host name into an InetAddress for ES network settings. If InetAddress.getByName cannot resolve the host it throws this IllegalStateException advising to check network settings and the relevant sonar property (e.g. sonar.search.host / node transport host).
Source
Thrown at server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java:206
private InetAddress resolveAddress(ProcessProperties.Property prop) {
return resolveAddress(prop, null);
}
private InetAddress resolveAddress(ProcessProperties.Property prop, @Nullable InetAddress defaultAddress) {
String address;
if (defaultAddress == null) {
address = props.nonNullValue(prop.getKey());
} else {
address = props.value(prop.getKey());
if (address == null) {
return defaultAddress;
}
}
try {
return InetAddress.getByName(address);
} catch (UnknownHostException e) {
throw new IllegalStateException("Can not resolve host [" + address + "]. Please check network settings and property " + prop.getKey(), e);
}
}
private void configureCluster(Map<String, String> builder) {
// Default value in a standalone mode, not overridable
String initialStateTimeOut = "30s";
if (clusterEnabled) {
initialStateTimeOut = props.value(SEARCH_INITIAL_STATE_TIMEOUT.getKey(), "120s");
String nodeSearchHost = resolveAddress(CLUSTER_NODE_SEARCH_HOST, loopbackAddress).getHostAddress();
int nodeSearchPort = props.valueAsInt(CLUSTER_NODE_SEARCH_PORT.getKey(), 9001);
builder.put(ES_HTTP_HOST_KEY, nodeSearchHost);
builder.put(ES_HTTP_PORT_KEY, valueOf(nodeSearchPort));
String nodeTransportHost = resolveAddress(CLUSTER_NODE_ES_HOST, loopbackAddress).getHostAddress();
int nodeTransportPort = props.valueAsInt(CLUSTER_NODE_ES_PORT.getKey(), 9002);View on GitHub (pinned to 184c821202)
Solutions
- Fix the host property reported in the message to a resolvable hostname or a valid IP address
- Verify DNS resolution from the server host: `getent hosts <name>` or `nslookup <name>`
- In containers/clusters, use the service DNS name or pod IP and ensure it is registered before SonarQube starts
- Use 0.0.0.0 only where binding-all-interfaces is intended; prefer explicit interface addresses
Example fix
# before sonar.search.host=search.internal.example # unresolvable # after sonar.search.host=192.168.1.25 # or fix DNS for search.internal.example
Defensive patterns
Strategy: validation
Validate before calling
// Verify resolvability before startup
InetAddress a = InetAddress.getByName(props.get("sonar.search.host")); // throws UnknownHostException early, with clear context
log.info("sonar.search.host resolves to {}", a.getHostAddress()); Try / catch
try { InetAddress.getByName(host); } catch (UnknownHostException e) { throw new IllegalStateException("Unresolvable host configured: " + host, e); } Prevention
- Test DNS from the server host (getent hosts) before starting
- Use IP addresses where DNS is unreliable (bare containers, early boot)
- In Kubernetes, verify the Service DNS record exists before app start (initContainers/wait-for)
- Keep host properties consistent between web and search nodes
When it happens
Trigger: sonar.search.host, sonar.cluster.node.host, or the transport host property contains a hostname DNS cannot resolve, or an invalid literal address, at ES settings build time.
Common situations: Typo in hostname in sonar.properties; DNS not available in the container/K8s pod; using a hostname before the service record exists; configuring 0.0.0.0-style values incorrectly.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- Can not resolve host [
- Address in property %s is not a valid address: %s
- Can not resolve host [
- Failed to validate configuration, check URL and Private Key
- Could not validate GitLab write permission. Got an unexpecte
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/a427f64f58847835.
Report an issue: GitHub.