Run from source Elasticsearch and connect Kibana

Hello,

I'm trying to setup environment for contribution into the project. I was able to run Elasticsearch from sources by running:

./gradlew run

I verified that the server is up and running by:
curl -u elastic:password "http://localhost:9200"

Here is the response:

{
  "name" : "runTask-0",
  "cluster_name" : "runTask",
  "cluster_uuid" : "dJfGG-pNScCtiSYbVpat0g",
  "version" : {
    "number" : "9.1.0-SNAPSHOT",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "c59406723deef99b9f78aba1935a100465486ef0",
    "build_date" : "2025-02-07T19:58:50.087143Z",
    "build_snapshot" : true,
    "lucene_version" : "10.1.0",
    "minimum_wire_compatibility_version" : "8.19.0",
    "minimum_index_compatibility_version" : "8.0.0"
  },
  "tagline" : "You Know, for Search"
}

Then I run kibana inside docker container by

Then once I open Kibana in browser it asks enrollment tocken. But I don't see it in Elasticsearch logs.

I tried to use "Configure manually" button and put there http://localhost:9200 but connection refused. Logs from Kibana:

[ERROR][plugins.interactiveSetup.elasticsearch] Unable to connect to host "http://localhost:9200": connect ECONNREFUSED 127.0.0.1:9200

When I tried to run:

curl -u elastic:password "http://localhost:9200/_security/enroll/kibana"

The response is:

{"error":{"root_cause":[{"type":"security_exception","reason":"Enrollment mode is not enabled. Set [xpack.security.enrollment.enabled] to true, in order to use this API."}],"type":"security_exception","reason":"Enrollment mode is not enabled. Set [xpack.security.enrollment.enabled] to true, in order to use this API."},"status":403}

Could someone support me on setting local dev env to have Elasticsearch run from source code and Kibana (may be there is better way other than from docker) connected to this local instance of Elasticsearch?

Really appreciate any help!

Try this ….

Good morning!

unfortunately I don't have bin directory as I run Elasticsearch not from distribution package but from source code. Also when I tried to make rest request to http://localhost:9200/_security/enroll/kibana it responds with Enrollment mode is not enabled. Set [xpack.security.enrollment.enabled] to true, in order to use this API.. So for me it looks like when I run locally from source some security options are disabled so Kibana should directly connect to Elasticsearch instance without enrollment token.
Or most likely I'm missing something :slight_smile:

Using localhost means that Kibana will try to connect to a Elasticsearch instance running on the same server/container, which is not the case.

If your Elasticsearch is running in the host machine, you need to set the correct IP address in Kibana.

Did you set xpack.security.enrollment.enabled to true in elasticsearch.yml and restarted Elasticsearch?

More for future reference, but do you have a elasticsearch-cli after building from source?

elasticsearch-create-enrollment-token is not that complex, just a bash script wrapper around elasticsearch-cli. And elasticsearch-cli is itself just a shell script that launches java with appropriate classes/libraries/settings.

But, in your original post you wrote:

So you have elasticsearch running outside of docker, and kibana inside a docker container? So when you wrote:

you were not executing this inside the kibana container, which is why you got a response.

Why not just download and run kibana on same host, directly, as with your source-built elasticsearch? At least without a little effort, your processes inside the container cannot talk to the processes on the host itself.

Also

This is obviously ahead of the official releases of elasticsearch, so you might hit some issues when using the official kibana releases.

Yeah, it looks like one of main issues of connection refused was exactly that. I tried to put localhost for Kibana container, but it reference to container localhost and not my host machine.

To fix this issue I started to use instead of locahost :slight_smile:

btw do you know where I can set xpack.security.enrollment.enabled property. Is it the right config that will be picked up by process run from sources:
distribution/src/config/elasticsearch.yml
?

Thank you

I didn't find elasticsearch-cli after building from source. The root cause of connection issue was exactly about localhost in docker container.
Once I fixed it I populate the password for kibana_system through API and it looks like it works except the fact that I'm running Elasticsearch from origin/main that contains 9.1.0-SNAPSHOT version of Elasticsearch. So now i'm receiving

As you mentioned latest docker official kibana version doesn't support it. So i will try to change my branch to some lower (released) version of elasticsearch

Thank you

As I said, the other elasticsearch-* tools are just shell wrappers of different java calls. You can download a tar file and look at them. (I have no idea if they are differently licensed)

You can close this thread by accepting one of the answers.

Good luck with your project.