Skip to content
Latchkey

Elasticsearch "missing authentication credentials for REST request" in CI

Elasticsearch 8.x turns X-Pack security on by default, so every REST request must authenticate. A client that connected fine against a 7.x dev cluster now gets "missing authentication credentials". For CI you either disable security or pass the built-in user credentials.

What this error means

Requests return HTTP 401 with "missing authentication credentials for REST request [/...]". It appears immediately after upgrading a service container to Elasticsearch 8.x.

elasticsearch
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication
credentials for REST request [/_cluster/health]"}],"type":"security_exception"},"status":401}

Common causes

Security is on by default in 8.x

Unlike 7.x dev mode, an 8.x node enforces authentication out of the box, so anonymous requests are rejected with 401.

The client sends no credentials

A test client configured for an open cluster sends no basic-auth header, so the request has no credentials to authenticate.

How to fix it

Disable security for a throwaway test cluster

  1. Set xpack.security.enabled=false on the service container.
  2. This restores open, unauthenticated HTTP for the test cluster.
  3. Only do this for ephemeral CI clusters, never for anything reachable outside the job.
.github/workflows/ci.yml
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.13.4
    env:
      discovery.type: single-node
      xpack.security.enabled: "false"

Or authenticate with the elastic user

Keep security on and pass the built-in elastic user password (set via ELASTIC_PASSWORD) on every request.

Terminal
curl -u elastic:"$ELASTIC_PASSWORD" http://localhost:9200/_cluster/health

How to prevent it

  • Decide per environment: disable security for CI, or wire credentials into the client.
  • Set ELASTIC_PASSWORD explicitly so it does not vary between runs.
  • Pin the Elasticsearch major version so security defaults do not change under you.

Frequently asked questions

What causes ""missing authentication credentials for REST request""?
Unlike 7.x dev mode, an 8.x node enforces authentication out of the box, so anonymous requests are rejected with 401.
How do I fix "missing authentication credentials for REST request"?
Disable security for a throwaway test cluster

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card