{"record":{"id":"be65240862c02240","repo":"SonarSource/sonarqube","slug":"failed-to-write-es-configuration-files","errorCode":null,"errorMessage":"Failed to write ES configuration files","messagePattern":"Failed to write ES configuration files","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java","lineNumber":220,"sourceCode":"      Path httpKeyStoreLocation = esInstallation.getHttpKeyStoreLocation();\n      copyFile(httpKeyStoreLocation, Paths.get(esConfPath, httpKeyStoreLocation.toFile().getName()));\n      esInstallation.getHttpKeyStorePassword().ifPresent(s -> keyStoreCli.store(HTTP_KEYSTORE_PASSWORD_PROPERTY_KEY, s));\n    }\n  }\n\n  private static void copyFile(Path from, Path to) {\n    try {\n      Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);\n    } catch (IOException e) {\n      throw new IllegalStateException(\"Could not copy file: \" + from, e);\n    }\n  }\n\n  private static void storeElasticsearchLog4j2Properties(EsInstallation esInstallation) {\n    try (FileOutputStream fileOutputStream = new FileOutputStream(esInstallation.getLog4j2PropertiesLocation())) {\n      esInstallation.getLog4j2Properties().store(fileOutputStream, \"log4j2 properties file for ES bundled in SonarQube\");\n    } catch (IOException e) {\n      throw new IllegalStateException(\"Failed to write ES configuration files\", e);\n    }\n  }\n\n  private <T extends JvmOptions> Process launchJava(JavaCommand<T> javaCommand) {\n    ProcessId processId = javaCommand.getProcessId();\n    try {\n      ProcessBuilder processBuilder = create(javaCommand);\n      logLaunchedCommand(javaCommand, processBuilder);\n      return processBuilder.start();\n    } catch (Exception e) {\n      throw new IllegalStateException(format(\"Fail to launch process [%s]\", processId.getHumanReadableName()), e);\n    }\n  }\n\n  private static <T extends AbstractCommand> void logLaunchedCommand(AbstractCommand<T> command, ProcessBuilder processBuilder) {\n    LOG.atInfo()\n      .addArgument(command::getProcessId)\n      .addArgument(() -> command.getWorkDir().getAbsolutePath())","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java#L202-L238","documentation":"storeElasticsearchLog4j2Properties writes the generated log4j2 properties file into the ES temp conf directory via FileOutputStream + Properties.store. An IOException while opening or writing the file is wrapped in this IllegalStateException because ES cannot boot without its logging configuration.","triggerScenarios":"writeConfFiles() -> storeElasticsearchLog4j2Properties() when the FileOutputStream to <ES temp conf>/log4j2.properties cannot be opened or written — disk full, read-only filesystem, permissions.","commonSituations":"Disk full on the temp volume; temp directory permissions changed mid-flight; read-only root filesystem in containers; filesystem I/O errors.","solutions":["Free disk space on the filesystem holding sonar.path.temp.","Fix ownership/permissions of the ES temp conf directory.","Ensure the container/root filesystem is writable where temp resides.","Check dmesg/filesystem health for underlying I/O errors."],"exampleFix":"$ df -h /opt/sonarqube/temp\n$ sudo chown -R sonarqube:sonarqube /opt/sonarqube/temp\n$ sudo systemctl restart sonarqube","handlingStrategy":"try-catch","validationCode":"File conf = esTempConfDir;\nif (!conf.canWrite() || conf.getUsableSpace() < 10_000_000) {\n    throw new IllegalStateException(\"ES conf dir not writable or low disk: \" + conf);\n}","typeGuard":null,"tryCatchPattern":"try { launcher.launch(...); } catch (IllegalStateException e) { if (e.getMessage().equals(\"Failed to write ES configuration files\")) { checkDiskAndPermissions(); } }","preventionTips":["Monitor disk space on the temp filesystem.","Keep temp directory ownership stable across upgrades.","Avoid read-only root filesystems without a writable temp mount."],"tags":["filesystem","elasticsearch","file-write"],"backgroundTag":"file-write-failed","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}