{"record":{"id":"58870b874f5d7bb9","repo":"SonarSource/sonarqube","slug":"unable-to-get-mac-address-will-use-a-dummy-addres","errorCode":null,"errorMessage":"Unable to get mac address, will use a dummy address","messagePattern":"Unable to get mac address, will use a dummy address","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"server/sonar-server-common/src/main/java/org/sonar/server/platform/serverid/MacAddressProvider.java","lineNumber":51,"sourceCode":"/**\n * Used by {@link UuidFactoryImpl}. Heavily inspired by https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/common/MacAddressProvider.java\n */\nclass MacAddressProvider {\n\n  private static final Logger LOGGER = LoggerFactory.getLogger(MacAddressProvider.class);\n  private static final SecureRandom SECURE_RANDOM = new SecureRandom();\n  public static final int BYTE_SIZE = 6;\n\n  private MacAddressProvider() {\n    // only static stuff\n  }\n\n  public static byte[] getSecureMungedAddress() {\n    byte[] address = null;\n    try {\n      address = getMacAddress();\n    } catch (SocketException se) {\n      LOGGER.warn(\"Unable to get mac address, will use a dummy address\", se);\n      // address will be set below\n    }\n\n    if (!isValidAddress(address)) {\n      LOGGER.warn(\"Unable to get a valid mac address, will use a dummy address\");\n      address = constructDummyMulticastAddress();\n    }\n\n    byte[] mungedBytes = new byte[BYTE_SIZE];\n    SECURE_RANDOM.nextBytes(mungedBytes);\n    for (int i = 0; i < BYTE_SIZE; ++i) {\n      mungedBytes[i] ^= address[i];\n    }\n\n    return mungedBytes;\n  }\n\n  private static boolean isValidAddress(@Nullable byte[] address) {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-server-common/src/main/java/org/sonar/server/platform/serverid/MacAddressProvider.java#L33-L69","documentation":"MacAddressProvider builds part of the unique server id from the machine's MAC address. When getMacAddress() throws SocketException (no usable network interface), the code logs this warning and falls back to a dummy multicast address. Server-id generation still succeeds; the id is just derived from random munged bytes instead of a hardware address.","triggerScenarios":"Calling getSecureMungedAddress() on a host where enumerating network interfaces throws SocketException — e.g. containers/VMs with no NIC, restricted /sys access, or interfaces removed while enumerating.","commonSituations":"Minimal Docker/Kubernetes containers without loopback-exposed interfaces; chrooted/jailed environments; hosts where NetworkInterface.getNetworkInterfaces() fails due to permissions; temporary network stack issues during server startup.","solutions":["Verify the host has at least one network interface (ip link / ifconfig) and it is up.","Run the SonarQube process with permission to read network interface info (check seccomp/AppArmor/selinux policies in containers).","If the server id was already generated with the dummy address, be aware it may differ between hosts — persist and reuse the generated server id instead of regenerating.","Restart the server once networking is healthy so a real MAC can be used.","This warning alone is harmless; investigate only if server-id instability or licensing keys depend on it."],"exampleFix":"// before: container started with --network none\n// after\ndocker run --network bridge ... sonarqube","handlingStrategy":"fallback","validationCode":"# verify at least one NIC with a MAC exists before starting the server\nip -o link | grep -v lo || echo 'WARNING: no usable network interface for server id generation'","typeGuard":null,"tryCatchPattern":"// the code already falls back to a dummy address; callers should persist the generated server id\nbyte[] munged = MacAddressProvider.getSecureMungedAddress();\n// store munged/serverId so restarts on NIC-less hosts stay stable","preventionTips":["Run SonarQube in networks with at least one up interface.","Avoid --network none for containers that generate server ids.","Persist the generated server id and reuse it across restarts.","Check container security policies blocking interface enumeration."],"tags":["sonarqube","network","server-id","environment"],"backgroundTag":"missing-network-interface","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"}