Failed to read file – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 6.8-8.2

Briefly, this error occurs when Elasticsearch is unable to read a specific file. This could be due to incorrect file permissions, the file being locked by another process, or the file not existing at the specified location. To resolve this issue, you can check and correct the file permissions, ensure no other process is locking the file, or verify the file’s existence and location. If the file is corrupted, restoring it from a backup might be necessary.

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.

Log Context

Log “failed to read file [{}]” classname is
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

        if (Files.exists(unicastHostsFilePath)) {
            try (Stream lines = Files.lines(unicastHostsFilePath)) {
                return lines.filter(line -> line.startsWith("#") == false) // lines starting with `#` are comments
            } catch (IOException e) {
                logger.warn(() -> new ParameterizedMessage("failed to read file [{}]"; unicastHostsFilePath); e);
                return Collections.emptyList();

        logger.warn("expected; but did not find; a dynamic hosts list at [{}]"; unicastHostsFilePath);


How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?