Unable to authenticate user for REST request

Hi

I am running the folowing comand:

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "ELASTICSEARCH_USERNAME=egid" -e "ELASTICSEARCH_PASSWORD=black" -e "xpack.security.enabled=true" docker.elastic.co/elasticsearch/elasticsearch:7.12.0

Everything runs fine.

I do post request from postman: (I filled username and password like arguments in docker command)

When I try post request on elastic search with basic auth I got this::

I got:

{
  "error": {
      "root_cause": [
        {
          "type": "security_exception",
          "reason": "unable to authenticate user [egid] for REST request [/event5/_search]",
          "header": {
          "WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
          }
        }
      ],
      "type": "security_exception",
     "reason": "unable to authenticate user [egid] for REST request [/event5/_search]",
     "header": {
        "WWW-Authenticate": "Basic realm=\"security\" charset=\"UTF-8\""
     }
  },
  "status": 401
}

Any ideas please ?:slight_smile:
Thank you for any help

I never used myself the ELASTICSEARCH_USERNAME variable. Could you try with elastic as the username in postman instead?

1 Like

Thank you very much:

It worked :slight_smile: but I also had to change to docker command to:
(use ELASTIC_PASSWORD instead of ELASTICSEARCH_PASSWORD)

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "ELASTIC_PASSWORD=black" -e "xpack.security.enabled=true" docker.elastic.co/elasticsearch/elasticsearch:7.12.0

also i did tried to play with ELASTICSEARCH_USERNAME and ELASTIC_USERNAME
but no result

IIRC the ELASTICSEARCH_PASSWORD and ELASTICSEARCH_USERNAME are for the Kibana Docker image.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.