{"record":{"id":"cfb63258f4367bbb","repo":"SonarSource/sonarqube","slug":"can-not-retrieve-network-interfaces","errorCode":null,"errorMessage":"Can not retrieve network interfaces","messagePattern":"Can not retrieve network interfaces","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/sonar-process/src/main/java/org/sonar/process/NetworkUtilsImpl.java","lineNumber":169,"sourceCode":"    boolean ipv6Preferred = Boolean.parseBoolean(System.getProperty(\"java.net.preferIPv6Addresses\"));\n\n    if (inetAddress.isEmpty() || inetAddress.get().isLoopbackAddress()) {\n      return ipv6Preferred;\n    }\n    return inetAddress.get() instanceof Inet6Address;\n  }\n\n  @Override\n  public Optional<InetAddress> getLocalInetAddress(Predicate<InetAddress> predicate) {\n    try {\n      return Collections.list(NetworkInterface.getNetworkInterfaces()).stream()\n        .flatMap(ni -> Collections.list(ni.getInetAddresses()).stream())\n        .filter(a -> a.getHostAddress() != null)\n        .filter(predicate)\n        .findFirst();\n    } catch (SocketException e) {\n      LOG.trace(\"getLocalInetAddress(Predicate<InetAddress>) failed\", e);\n      throw new IllegalStateException(\"Can not retrieve network interfaces\", e);\n    }\n  }\n}\n","sourceCodeStart":151,"sourceCodeEnd":173,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-process/src/main/java/org/sonar/process/NetworkUtilsImpl.java#L151-L173","documentation":"getLocalInetAddress enumerates NetworkInterfaces and their InetAddresses filtered by a predicate. A SocketException during enumeration is wrapped into IllegalStateException 'Can not retrieve network interfaces'.","triggerScenarios":"NetworkInterface.getNetworkInterfaces()/getInetAddresses() throwing SocketException — e.g. network stack unavailable or restricted at JVM startup.","commonSituations":"Containers with missing /proc/net or restricted netns; VPN or virtual adapters in a broken state; minimal OS images lacking networking setup.","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"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  InetAddress addr = networkUtils.getLocalInetAddress(a -> true);\n} catch (IllegalStateException e) {\n  LOGGER.error(\"Network interfaces unavailable; check container/host networking\", e);\n}","preventionTips":["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"],"tags":["network","interfaces","socket"],"backgroundTag":"network-request-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}