Migrating to Elasticsearch 5.4.0 on Heroku using Elastic Cloud: [indices:admin/delete] requires authentication.

Aaron Careaga
May 31, 2017 · 1 min read

I learned the hard way how to setup access authentication for a protected cluster after upgrading to Elasticsearch 5.4.0 on Heroku’s Elastic Cloud service. Our previous instance did not require Shield access authentication.

After porting the changes and pushing the upgrade, I hit the following error when rebuilding indices:

Elasticsearch::Transport::Transport::Errors::Unauthorized: [401] {“error”:{“root_cause”:[{“type”:”security_exception”,”reason”:”action [indices:admin/delete] requires authentication”,”header”:{“WWW-Authenticate”:”Basic realm=\”security\” charset=\”UTF-8\””}}],”type”:”security_exception”,”reason”:”action [indices:admin/delete] requires authentication”,”header”:{“WWW-Authenticate”:”Basic realm=\”security\” charset=\”UTF-8\””}},”status”:401}

To setup access authentication using a transport service:

(1) Install and configure the `elasticsearch-transport` gem (or alternative for non-Rails projects)

gem 'elasticsearch-transport', '~> 5.0.4'

(2) Push changes to Heroku server

$ git push heroku <app-name> <branch-name>

(3) Update your version on Elastic Cloud. This is accessible from the Heroku Dashboard add-on section.

Version: 5.4.0

Note: Shield is enabled by default. Save the auto-generated password that is provided for the `elastic` user.

(4) Using `elastic` credentials, log into Kibana and create an additional superuser. This is accessible from the Elastic Cloud dashboard, click on Kibana and then the management tab and elasticsearch security.

# Elasticsearch security via Kibana management tab
user: <user>
pass: <password>
role: superuser

(5) Set the access credentials on the config variable `FOUNDELASTICSEARCH_URL` like:


This is accessible from your Heroku dashboard settings tab.

(6) Run rake commands to rebuild indices on Heroku environment.

$ heroku run rake elasticsearch:import:all

You should be good to go now.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store