Opster Team
Before you begin reading this guide, we recommend you run Elasticsearch Error Check-Up which analyzes 2 JSON files to detect many errors.
Briefly, this error is indicating that Elasticsearch is unable to read a specific file. This could be due to issues with file permissions or the file not being present in the expected location. To resolve this issue, check the file’s location and make sure that the correct permissions are set for Elasticsearch to be able to access it.To easily locate the root cause and resolve this issue try AutoOps for Elasticsearch & OpenSearch. It diagnoses problems by analyzing hundreds of metrics collected by a lightweight agent and offers guidance for resolving them. Take a self-guided product tour to see for yourself (no registration required).
This guide will help you check for common problems that cause the log ” Failed to read file ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: discovery-azure-classic, discovery-file and hosts.
Log Context
Log “Failed to read file [{}]” classname is FileBasedUnicastHostsProvider.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :
private ListreadFileContents(Path path) { try (Stream lines = Files.lines(path)) { return lines.filter(line -> line.startsWith("#") == false) // lines starting with `#` are comments .collect(Collectors.toList()); } catch (IOException e) { logger.warn(() -> new ParameterizedMessage("failed to read file [{}]"; unicastHostsFilePath); e); return Collections.emptyList(); } } Override
Find & fix Elasticsearch problems
Opster AutoOps diagnoses & fixes issues in Elasticsearch based on analyzing hundreds of metrics.
Fix Your Cluster IssuesConnect in under 2 minutes
Matt Watson
CTO at Stackify