DigitalOcean Droplet: Unable to locate package Elasticsearch

I used the DigitalOcean 1-Click-Install Mastodon droplet, to set up a Mastodon instance. It has been working quite well. I have been attempting to set up Elasticsearch.

First I tested whether some or all of the Elasticsearch setup was already set up as part of the 1 Click Install image. I uncommented the following lines in mastodon/.env.production.sample:


That did not get search working with anything that might have come pre-installed in the image.

Next I followed these instructions in the tootsuite docs on Github.

When I reached the step to run sudo apt update && sudo apt install elasticsearch, it said it was unable to locate the package.

I went back to the previous command, sudo echo "deb stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list.

I opened up /etc/apt/sources.list.d in an editor. Elasticsearch source had not been added to that source list.

apt-get update only shows sources for ubuntu, debian, and node_8.x.

So I tried surfing in a web browser to The browser said it was not found.

Installing sudo apt-get install apt-transport-https worked just fine; that’s not the problem.

I went to the documentation on the elasticsearch website for how to install their deb package. The commands seem to be the same, except using 7.x instead of 6.x.

But this led to the same thing: Unable to locate package elasticsearch.

Next I tried the option (still on the Elasticsearch installation documentation page) to download and install the package manually.

But still, when I ran:

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service

… it still said Failed to enable unit: Unit file elasticsearch.service does not exist.

What next steps do you recommend?

@Gargron, as you created the Droplet image, do you know what’s up with this issue? Thank you! It was easy as pie to create my instance! If I can’t get Elasticsearch, that’s OK.” also shows up as 404 not found, so i’m guessing that’s probably a red herring (the apt repository directory structure is pretty deeply nested, and it looks like they have directory indexes turned off)

Did you run wget -qO - | sudo apt-key add - yet? You haven’t mentioned anything about it.

You mentioned that /etc/apt/source.list didn’t contain anything about elasticsearch, but did you check that the file the tee command was writing to exists? this one: /etc/apt/sources.list.d/elastic-6.x.list

I would recommend installing the 6.x elasticseach release, I don’t know if the latest mastodon is compatible with elasticsearch 7 yet

Yes, I took all the steps up to the systemd commands, and did not skip any-- including that one. Good thought though.

/etc/apt/sources.list.d/elastic-6.x.list doesn’t exist.

So I ran touch /etc/apt/sources.list.d/elastic-6.x.list.

Then I ran sudo echo "deb stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list and yet the process still failed the same way.

So I navigated to elastic-6.x.list, opened it with nano, and pasted in deb stable main, saved it and closed it.

This time attempting to apt install it complains about the GPG key.

W: GPG error: stable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY [ redacted ]
E: The repository ' stable Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

The command wget -qO - | sudo apt-key add - appears to have failed silently.

I tried apt-keys list and the output did not mention anything about elasticsearch. If it were an SSH public key file I could open it in nano and edit it, but /etc/apt/trusted.gpg and all the files in /etc/apt/trusted.gpg.d are encrypted and appear as gibberish.

I greatly appreciate your response!

if you just do sudo echo 1 what happens? It’s possible these commands are all failing because they’re waiting for you to authenticate

It responds with 1, so I’m authenticated, but that’s an excellent point. I’ve been logged in as root this whole time. I tried su - mastodon just now, but running the commands as that user did not improve anything.

I think I got it to work without apt. I discovered the Elasticsearch site offers a direct download of version 6.7. (Ironically for a site about search, I couldn’t find it on their site until I used Google.) Once I found that page, I right-clicked the deb download link to copy its URL. I found that I need to find-and-replace 7.1.0-amd64 with 6.7.0, and this time it downloaded the package:

shasum -a 512 -c elasticsearch-6.7.0.deb.sha512 
sudo dpkg -i elasticsearch-6.7.0.deb

Following the rest of the installation instructions seems to have gone successfully.

It failed because of insufficient memory on my 1GB droplet, but that’s an issue for another day!

Thank you!