illegal_argument_exception is the most common Elasticsearch error class - returned with 400 Bad Request whenever the server rejects a request argument: a setting it does not recognize, a value it cannot parse, a parameter outside the allowed range, or a state the cluster is not in. The exception is sometimes also surfaced in clients as ElasticsearchIllegalArgumentException (or ElasticsearchStatusException wrapping it). No cluster state is changed; only the failing request is rejected.
What This Error Means
illegal_argument_exception is Elasticsearch's general-purpose validation rejection. It can come from settings APIs (unknown setting, wrong type, non-dynamic setting), query DSL (unknown query type, missing required field), index operations (mapper conflicts, type mismatches), or admin APIs (invalid cluster state transition).
The exception message names the rejected argument precisely. The fix is almost always "read the message, fix the input, retry".
Common Causes
- Unknown setting or parameter name (typo, deprecated, x-pack-only). How to confirm: error reads
unknown setting [<name>]orrequest [...] contains unrecognized parameter [<name>]. - Value of wrong type or out of range (e.g.,
"number_of_shards": "abc","refresh_interval": "-1s"). How to confirm: error readsFailed to parse value [<value>] for setting/parameter [<name>]. - Mapper conflict on existing field. How to confirm: error reads
mapper for [<field>] conflicts with existing mapper; see the dedicated mapper conflicts page. - Static setting modified on a running index. How to confirm: error reads
Can't update non dynamic settings. - Cluster state transition violation (e.g., trying to reroute a shard that is already started). How to confirm: error message includes the current and requested state.
- API used outside its license tier. How to confirm: error includes "license" or mentions a feature unavailable on the current tier.
How to Fix IllegalArgumentException
Read the full error. Add
?error_trace=true:curl -X POST 'https://es:9200/my-index/_search?error_trace=true' \ -H 'Content-Type: application/json' -d '{...}'The first sentence of the message names the rejected argument.
Check the API reference for the running version. Many parameters have changed across major versions.
For unknown settings, confirm the name in index modules or cluster settings reference.
For "Can't update non dynamic settings", create a new index with the desired static settings and reindex:
PUT /my-index-v2 { "settings": { "number_of_shards": 6 } } POST _reindex { "source": {"index": "my-index"}, "dest": {"index": "my-index-v2"} }For mapper conflicts, see the dedicated page.
For deprecated parameters, check the deprecation log (
<log_dir>/<cluster>_deprecation.log) for warnings about renames that have since become errors.Bisect complex requests. Remove arguments until the error stops; the last addition is the cause.
Resolve illegal_argument_exception Automatically with Pulse
Pulse is an AI DBA for Elasticsearch and OpenSearch. When illegal_argument_exception (or its ElasticsearchIllegalArgumentException wrapper) returns 400, Pulse:
- Groups recurring
illegal_argument_exceptionevents by error-message signature, attributes each group to the responsible client viaX-Opaque-Id/User-Agent, cross-references<log_dir>/<cluster>_deprecation.logfor matching renames, and readsGET /for server version - Identifies which of the six causes applies: unknown setting/parameter name, value of wrong type or out of range, mapper conflict on existing field, static setting modified on a running index, cluster state transition violation (e.g., reroute on an already-started shard), or licensed-feature mismatch
- Generates the exact remediation: the version-appropriate parameter or setting name from the running version's API reference, the
PUT /my-index-v2 { settings: {...} }plusPOST _reindexplan for static-setting changes, or the per-cause KB-page link (mapper conflicts, parsing exceptions) - Applies dynamic settings updates with operator approval; leaves reindex and client library upgrades as one-click PRs targeting the calling service
Pulse surfaces deprecation log entries before they become breaking errors in a major upgrade, so the _type or include_type_name removal is tracked rather than a surprise on the upgrade weekend.
Start a free trial to connect your cluster.
Frequently Asked Questions
Q: What is the difference between illegal_argument_exception and parsing_exception?
A: parsing_exception indicates malformed JSON or wrong query DSL structure (Elasticsearch could not parse the body shape). illegal_argument_exception indicates the body parsed successfully but an argument value or name is rejected by validation. Both return 400.
Q: How do I find out which argument is invalid?
A: The error message names the argument explicitly. Add ?error_trace=true to the request for the full stack trace. The deprecation log lists renames and removals.
Q: Can illegal_argument_exception be caused by version incompatibility?
A: Yes. Major versions remove deprecated parameters and APIs. Mapping types were removed in 8.0; many xpack.* settings moved to core in 7.x. Match the client library to the server's major version.
Q: Will retrying an illegal_argument_exception eventually succeed?
A: No. The rejection is deterministic. Same request, same response. Fix the argument before retrying.
Q: Does illegal_argument_exception affect cluster stability?
A: No. Validation happens before any work is dispatched. The rejected request returns 400; no shard or cluster state is changed. Other requests continue normally.
Q: Can a cluster setting change cause an immediate illegal_argument_exception across multiple clients?
A: Yes, if you enable a stricter validation or change a default. Setting action.destructive_requires_name: true, for example, makes wildcard DELETEs return illegal_argument_exception. Plan setting changes deliberately.
Q: What's the fastest way to diagnose illegal_argument_exception in production?
A: Pulse, the AI DBA for Elasticsearch and OpenSearch, groups recurring illegal_argument_exception events by signature, attributes each to the responsible client, and cross-references the deprecation log so the rejected argument has a named cause and version-appropriate replacement before anyone opens the Elasticsearch reference docs.
Related Reading
- Elasticsearch IllegalArgumentException: mapper conflicts: the mapping-specific variant.
- Elasticsearch parsing exception: for JSON/body shape errors.
- Elasticsearch InvalidParameterException: closely related parameter errors.
- Elasticsearch index creation fails: invalid settings: create-index-specific variant.
- Elasticsearch monitoring: grouped 4xx error monitoring.