Exception while closing %s – How to solve this Elasticsearch error

Opster Team

Aug-23, Version: 8.4-8.9

Briefly, this error occurs when Elasticsearch encounters an issue while trying to close a session or connection. This could be due to network issues, resource limitations, or a problem with the underlying storage system. To resolve this issue, you can try restarting Elasticsearch, checking the network connection, ensuring there are sufficient resources available, or investigating the health of the storage system. If the problem persists, you may need to check the Elasticsearch logs for more detailed error information.

This guide will help you check for common problems that cause the log ” Exception while closing [%s] ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: indices, recovery.

Log Context

Log “Exception while closing [%s]” classname is RecoverySourceHandler.java.
We extracted the following from Elasticsearch source code for those seeking an in-depth context :

        threadPool.generic().execute(() -> {
            try {
            } catch (Exception e) {
                assert false : e;
                logger.warn(() -> format("Exception while closing [%s]"; closeable); e);

    record SendFileResult(