Unable to install elasticsearch on ubuntu

Hello, I'm back. So I'm on Ubuntu Desktop now and trying to install Elasticsearch on the local terminal.

The problem, I get an error that says it can't find the package. Here is the error message I get

(venv) corey-james@corey-james-HP-Laptop-14-dq0xxx:~/Arborhub/MyProject$ sudo apt install elasticsearch
Error: Unable to locate package elasticsearch

Please let me know if you need additional information. Thank you

Hello,

Did you follow the instructions in the documentation?

You need to add Elastic repository first.

Thank you. Yes I was following the docs and when I tried start Elasticsearch with sudo systemctl start elasticsearch.service this is the output I got

(venv) corey-james@corey-james-HP-Laptop-14-dq0xxx:~/Arborhub/MyProject$ sudo systemctl start elasticsearch.service

I think the server started successfully, but since there was no output, I wanted to make sure

I ran this command as per the docs to verify elasticsearch is running curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200 and got this output

stemctl start kibana.service
(venv) corey-james@corey-james-HP-Laptop-14-dq0xxx:~/Arborhub/MyProject$ curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200 
curl: (77) error setting certificate file: /etc/elasticsearch/certs/http_ca.crt

Hi Corey

Optimistic! Nothing wrong with optimism.

There was no output pasted, just the command itself, but if the sudo apt install elasticsearch failed and you didn't address that, then it's not working.

Can I suggest you go back to step one, and cut and paste every single command and its output. I also note your prompt starts with "(venv)" suggesting you setup some kind of python virtual environment. Thats typically fine, should not impact installing elasticsearch/kibana, but if you are inexperienced linux user it's possible your environment is a little messed up.

Try this too:

$ apt list --installed | grep elasticsearch or $ apt list elasticsearch

Output will contain something like this if Elasticsearch is properly installed:

elasticsearch/now 8.17.3 amd64 [installed,local]
(venv) corey-james@corey-james-HP-Laptop-14-dq0xxx:~/Arborhub/MyProject$ apt list --installed | grep elasticsearch

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

elasticsearch/stable,now 8.17.4 amd64 [installed]

I can also paste from the terminal, from the beginning of the elasticsearch installation command if you'd like

Yeah I doubt Python virtual environment would have any kind of effect on elasticsearch.

I didn't have an existing node, so the last command I wrote in the docs was
sudo systemctl start elasticsearch.service.

that is much better. Now try your curl command with sudo as

sudo ls -l /etc/elasticsearch/certs/http_ca.crt
-rw-rw---- 1 root elasticsearch 1915 Feb 20 00:44 /etc/elasticsearch/certs/http_ca.crt

unless your local user is in the elasticsearch group, that file would not be readable as a normal user.

should see something like:

$ sudo curl --cacert /etc/elasticsearch/certs/http_ca.crt -u "${EUSER}:${EPASS}" https://localhost:9200
{
  "name" : "u2024",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "xxxxx",
  "version" : {
    "number" : "8.17.3",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "a091390de485bd4b127884f7e565c0cad59b10d2",
    "build_date" : "2025-02-28T10:07:26.089129809Z",
    "build_snapshot" : false,
    "lucene_version" : "9.12.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

btw equivalent but not needing sudo is probably

$ curl -k -u "${EUSER}:${EPASS}" https://localhost:9200

(venv) corey-james@corey-james-HP-Laptop-14-dq0xxx:~/Arborhub/MyProject$ sudo ls -l /etc/elasticsearch/certs/http_ca.crt
-rw-rw---- 1 root elasticsearch 1915 Feb 20 00:44 /etc/elasticsearch/certs/http_ca.crt
[sudo] password for corey-james: 
-rw-rw---- 1 root elasticsearch 1915 Mar 30 15:28 /etc/elasticsearch/certs/http_ca.crt
-rw-rw----: command not found

something very weird about that output ... you pasted both the command and my output into your terminal. Anyways, it was what I said, the file /etc/elasticsearch/certs/http_ca.crt is only readable by the elasticsearch user and those in the elasticsearch group, which probably does not include the (local) linux user corey-james

put a sudo before your curl command and it should work.

I due apologize, like this?

(venv) corey-james@corey-james-HP-Laptop-14-dq0xxx:~/Arborhub/MyProject$ sudo ls -l /etc/elasticsearch/certs/http_ca.crt
-rw-rw---- 1 root elasticsearch 1915 Mar 30 15:28 /etc/elasticsearch/certs/http_ca.crt

So I don't elasticsearch is running, as it doesn't work with curl

I can’t really make that suggestion any simpler.

Do you understand why you got the previous error:

?

It's because you, meaning user= corey-jame, do not have permissions to read the file. So you need run the curl commands with sudo. Or just use the other option, with -k, which doesn’t need sudo and doesn’t need the —cacert option.

These are very basic Linux/shell topics, not really anything directly to do with elasticsearch. Sorry, but you are likely going to need to get much more familiar with Linux/shell topics to get too much further.

1 Like