elastic/elasticsearch · error · WarningFailureException

method [%s], host [%s], URI [%s], status line [%s]

Error message

method [%s], host [%s], URI [%s], status line [%s]

What it means

This is the message format of ResponseException, thrown by RestClient.convertResponse when an Elasticsearch node replies with a non-success, non-retryable HTTP status (e.g. 4xx client errors). buildMessage formats the request method, host, URI, and status line into the exception text, then appends any warnings and the response body so the caller sees why the request was rejected.

Source

Thrown at client/rest/src/main/java/org/elasticsearch/client/RestClient.java:347

        RequestLogger.logResponse(logger, request.httpRequest, node.getHost(), httpResponse);
        int statusCode = httpResponse.getStatusLine().getStatusCode();

        HttpEntity entity = httpResponse.getEntity();
        if (entity != null) {
            Header header = entity.getContentEncoding();
            if (header != null && "gzip".equals(header.getValue())) {
                // Decompress and cleanup response headers
                httpResponse.setEntity(new GzipDecompressingEntity(entity));
                httpResponse.removeHeaders(HTTP.CONTENT_ENCODING);
                httpResponse.removeHeaders(HTTP.CONTENT_LEN);
            }
        }

        Response response = new Response(request.httpRequest.getRequestLine(), node.getHost(), httpResponse);
        if (isSuccessfulResponse(statusCode) || request.ignoreErrorCodes.contains(response.getStatusLine().getStatusCode())) {
            onResponse(node);
            if (request.warningsHandler.warningsShouldFailRequest(response.getWarnings())) {
                throw new WarningFailureException(response);
            }
            return new ResponseOrResponseException(response);
        }
        ResponseException responseException = new ResponseException(response);
        if (isRetryStatus(statusCode)) {
            // mark host dead and retry against next one
            onFailure(node);
            return new ResponseOrResponseException(responseException);
        }
        // mark host alive and don't retry, as the error should be a request problem
        onResponse(node);
        throw responseException;
    }

    /**
     * Sends a request to the Elasticsearch cluster that the client points to.
     * The request is executed asynchronously and the provided
     * {@link ResponseListener} gets notified upon request completion or

View on GitHub (pinned to db6a809a66)

Solutions

  1. Catch ResponseException, inspect getResponse().getStatusLine().getStatusCode() and the body to diagnose the underlying ES error.
  2. Fix the request per the ES error: correct query JSON, ensure index exists, grant permissions, resolve conflicts.
  3. For expected 404s, check getResponse().getStatusLine().getStatusCode() == 404 and handle gracefully instead of propagating.

Example fix

// before
Response r = client.performRequest(req); // throws ResponseException on 404
// after
try {
    Response r = client.performRequest(req);
} catch (ResponseException e) {
    if (e.getResponse().getStatusLine().getStatusCode() == 404) {
        // index not found - handle gracefully
    } else throw e;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    Response r = client.performRequest(req);
} catch (ResponseException e) {
    int code = e.getResponse().getStatusLine().getStatusCode();
    switch (code) {
        case 404: // not found - handle absent resource
        case 409: // conflict - retry or surface
        default: throw e;
    }
}

Prevention

When it happens

Trigger: Any request that returns a 4xx (or non-retryable error) status: malformed query JSON (400), missing index (404), auth failure (401/403), mapping conflict (400), etc. The exception is thrown at the end of convertResponse after marking the host alive.

Common situations: Query syntax error; referencing a non-existent index/alias; insufficient permissions; version conflict on update; oversized request; misconfigured mapping.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/13a0ccb17abd28c7. Report an issue: GitHub.