SonarSource/sonarqube · error
Failed to write ES configuration files
Error message
Failed to write ES configuration files
What it means
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.
Source
Thrown at server/sonar-main/src/main/java/org/sonar/application/ProcessLauncherImpl.java:220
Path httpKeyStoreLocation = esInstallation.getHttpKeyStoreLocation();
copyFile(httpKeyStoreLocation, Paths.get(esConfPath, httpKeyStoreLocation.toFile().getName()));
esInstallation.getHttpKeyStorePassword().ifPresent(s -> keyStoreCli.store(HTTP_KEYSTORE_PASSWORD_PROPERTY_KEY, s));
}
}
private static void copyFile(Path from, Path to) {
try {
Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new IllegalStateException("Could not copy file: " + from, e);
}
}
private static void storeElasticsearchLog4j2Properties(EsInstallation esInstallation) {
try (FileOutputStream fileOutputStream = new FileOutputStream(esInstallation.getLog4j2PropertiesLocation())) {
esInstallation.getLog4j2Properties().store(fileOutputStream, "log4j2 properties file for ES bundled in SonarQube");
} catch (IOException e) {
throw new IllegalStateException("Failed to write ES configuration files", e);
}
}
private <T extends JvmOptions> Process launchJava(JavaCommand<T> javaCommand) {
ProcessId processId = javaCommand.getProcessId();
try {
ProcessBuilder processBuilder = create(javaCommand);
logLaunchedCommand(javaCommand, processBuilder);
return processBuilder.start();
} catch (Exception e) {
throw new IllegalStateException(format("Fail to launch process [%s]", processId.getHumanReadableName()), e);
}
}
private static <T extends AbstractCommand> void logLaunchedCommand(AbstractCommand<T> command, ProcessBuilder processBuilder) {
LOG.atInfo()
.addArgument(command::getProcessId)
.addArgument(() -> command.getWorkDir().getAbsolutePath())View on GitHub (pinned to 184c821202)
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.
Example fix
$ df -h /opt/sonarqube/temp $ sudo chown -R sonarqube:sonarqube /opt/sonarqube/temp $ sudo systemctl restart sonarqube
Defensive patterns
Strategy: try-catch
Validate before calling
File conf = esTempConfDir;
if (!conf.canWrite() || conf.getUsableSpace() < 10_000_000) {
throw new IllegalStateException("ES conf dir not writable or low disk: " + conf);
} Try / catch
try { launcher.launch(...); } catch (IllegalStateException e) { if (e.getMessage().equals("Failed to write ES configuration files")) { checkDiskAndPermissions(); } } Prevention
- Monitor disk space on the temp filesystem.
- Keep temp directory ownership stable across upgrades.
- Avoid read-only root filesystems without a writable temp mount.
When it happens
Trigger: writeConfFiles() -> storeElasticsearchLog4j2Properties() when the FileOutputStream to <ES temp conf>/log4j2.properties cannot be opened or written — disk full, read-only filesystem, permissions.
Common situations: Disk full on the temp volume; temp directory permissions changed mid-flight; read-only root filesystem in containers; filesystem I/O errors.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- Can not open file
- Could not delete Elasticsearch temporary conf directory
- Failed to create temporary configuration directory [%s]
- Could not copy file:
- Cannot write Elasticsearch jvm options file
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/be65240862c02240.
Report an issue: GitHub.