Errors ("type" : "security_exception") in running ElasticSearch

Hi,

I have some difficulties when I run the elasticsearch on Windows. I wonder if you could help me in this process to solve the error.

My Java version is: java version "1.8.0_271"

I installed elasticsearch, successfully using .msi package GUI. I used the basic License of it. I'm using the elasticsearch for education as well. the curl was also installed.
In addition, I run the elasticsearch by the .\bin\elasticsearch and I got the following message in my Command Prompt:

Elasticsearch is already running as a service and currently: Running.

I opened localhost:9200 and I saw the elasticsearch is running.

When I want to follow along with the Getting Started Guide, for the first command related to Cluster Health I receive the following message shows it doesn't work properly:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "security_exception",
        "reason" : "missing authentication credentials for REST request [/_cat/health?v=true&pretty]",
        "header" : {
          "WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
        }
      }
    ],
    "type" : "security_exception",
    "reason" : "missing authentication credentials for REST request [/_cat/health?v=true&pretty]",
    "header" : {
      "WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
    }
  },
  "status" : 401
}

C:\>curl -X<VERB> '<PROTOCOL>://<HOST>:<PORT>/<PATH>?<QUERY_STRING>' -d '<BODY>'
The system cannot find the file specified.

Hi @SMH Welcome the community and thanks for trying Elasticsearch

Did you set up basic authentication ... it looks like you have if so the curl command needs to include the username and password like

curl -u username:password http://localhost:9200/

That last error -d is used when you wan to post a file or content if you are not do not include that

Thanks for your fast reply. I'm a bit confused.
I did it. This is why I opened localhost:9200.
In fact, before using "elasticsearch-setup-passwords auto", I could not open the localhost:9200 on the browser. After that, I put the generated password into the browser pop-up and opened localhost:9200.

I got the code "curl -X GET "localhost:9200/_cat/health?v&pretty"" from the following link to check the basic health. The error that I mentioned before, still appear, by the way.

Right but once you added authentication you need to add it to every curl command that you issues... We do not show that in the docs.

BTW you should be looking at the current docs here

curl -X GET -u elastic:generatedpassword "localhost:9200/_cat/health?v&pretty"

Also if you could please refrain form posting images instead of text they can not be searched etc and make it harder to help.

Thank you for your helpful comment.
The issue's solved.
I have one more question. Why might we break an index into shards?

Shards are a fundametal concept in elasticsearch

Perhaps take a look at these 2 blogs about shards and sizing

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