SonarSource/sonarqube · error · IllegalStateException
Can not retrieve network interfaces
Error message
Can not retrieve network interfaces
What it means
getLocalInetAddress enumerates NetworkInterfaces and their InetAddresses filtered by a predicate. A SocketException during enumeration is wrapped into IllegalStateException 'Can not retrieve network interfaces'.
Solutions
- Fix host/container networking so interfaces can be enumerated
- Verify `NetworkInterface.getNetworkInterfaces()` returns non-null on the host
- Restart the network stack or the container
- Inspect the wrapped SocketException cause
Example fix
null
Defensive patterns
Strategy: try-catch
Try / catch
try {
InetAddress addr = networkUtils.getLocalInetAddress(a -> true);
} catch (IllegalStateException e) {
LOGGER.error("Network interfaces unavailable; check container/host networking", e);
} Prevention
- Verify network interfaces exist before starting network-dependent processes
- Avoid broken VPN/virtual adapters on hosts running SonarQube
- Test networking in minimal container images before deployment
When it happens
Trigger: NetworkInterface.getNetworkInterfaces()/getInetAddresses() throwing SocketException — e.g. network stack unavailable or restricted at JVM startup.
Common situations: Containers with missing /proc/net or restricted netns; VPN or virtual adapters in a broken state; minimal OS images lacking networking setup.
Related errors
- Fail to find an available port on
- Address in property is not a valid address
- Can not resolve host [
- Can not resolve host [
- Can not resolve host [. Please check network settings and…
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/cfb63258f4367bbb.
Report an issue: GitHub.
Appendix: source
Thrown at server/sonar-process/src/main/java/org/sonar/process/NetworkUtilsImpl.java:169
boolean ipv6Preferred = Boolean.parseBoolean(System.getProperty("java.net.preferIPv6Addresses"));
if (inetAddress.isEmpty() || inetAddress.get().isLoopbackAddress()) {
return ipv6Preferred;
}
return inetAddress.get() instanceof Inet6Address;
}
@Override
public Optional<InetAddress> getLocalInetAddress(Predicate<InetAddress> predicate) {
try {
return Collections.list(NetworkInterface.getNetworkInterfaces()).stream()
.flatMap(ni -> Collections.list(ni.getInetAddresses()).stream())
.filter(a -> a.getHostAddress() != null)
.filter(predicate)
.findFirst();
} catch (SocketException e) {
LOG.trace("getLocalInetAddress(Predicate<InetAddress>) failed", e);
throw new IllegalStateException("Can not retrieve network interfaces", e);
}
}
}
View on GitHub (pinned to 184c821202)