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 orView on GitHub (pinned to db6a809a66)
Solutions
- Catch ResponseException, inspect getResponse().getStatusLine().getStatusCode() and the body to diagnose the underlying ES error.
- Fix the request per the ES error: correct query JSON, ensure index exists, grant permissions, resolve conflicts.
- 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
- Validate query JSON, index names, and mappings before sending requests.
- Inspect the status code and body in the catch to branch on expected vs unexpected errors.
- Handle common statuses (404, 409, 401/403) explicitly rather than propagating generic ResponseException.
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
- entity content is too long [{}] for the configured buffer li
- Failed to read http ports file: {} for {}
- Failed to download branches.json from: {}
- Uploading Snyk Graph failed with http code {}: {}
- Failed to call API endpoint to submit updated dependency gra
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/13a0ccb17abd28c7.
Report an issue: GitHub.