Skip to content
Latchkey

Elasticsearch "media_type_header_exception" / Content-Type not supported in CI

Elasticsearch rejected a request because the Content-Type or Accept header carried a compatibility version the server does not accept. This is a client and server version mismatch: an 8.x client sends a compatible-with=8 media type to a 7.x server, or vice versa, and the server returns media_type_header_exception.

What this error means

Requests fail with "media_type_header_exception" or "Content-Type header [application/vnd.elasticsearch+json; compatible-with=8] is not supported", usually right after upgrading either the client or the server.

elasticsearch
{"error":{"type":"media_type_header_exception","reason":"Content-Type header
[application/vnd.elasticsearch+json;compatible-with=8] is not supported"},"status":400}

Common causes

Client and server major versions differ

The client emits a compatible-with media type for its own major version, which the server on a different major does not support.

A mixed upgrade of client or server only

Bumping the client library without bumping the service image (or the reverse) leaves the compatibility header pointed at a version the other side does not accept.

How to fix it

Match the client major version to the server

  1. Pin the client library and the service container image to the same major version.
  2. Reinstall or rebuild so both sides agree.
  3. Re-run and confirm the media-type header is accepted.
.github/workflows/ci.yml
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.13.4
# and pin the client to a matching 8.x major

Keep both sides pinned

Pin the client dependency and the service image together so an unrelated upgrade cannot desynchronize the compatibility header.

How to prevent it

  • Pin the client and server to the same major version.
  • Upgrade the client library and the service image together.
  • Test against the exact server version you run in production.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →