Skip to main content

how to setup elasticsearch on Heroku?

Servers • Asked by Jeramae Bohol

I implemented the elasticsearch/searchkick on my app and it works on develoment. But it's not working on production. I did heroku logs and these are the errors:

"Completed 500 Internal Server Error in 16ms (Searchkick: 8.0ms | ActiveRecord: 0.0ms)"

"Faraday::ConnectionFailed (Connection refused - connect(2) for "localhost" port 9200):"


Here's an article on Bonsai which let's you do Elasticsearch on Heroku.

https://devcenter.heroku.com/articles/bonsai & https://docs.bonsai.io/docs/ruby-on-rails

I don't have any experience with running elasticsearch on heroku but give that article a shot and the docs on bonsai's site and see if that gets you to a better spot to troubleshoot with.


Actually the solution is in the searchkick readme https://github.com/ankane/searchkick#deployment


What I've noticed is that bonsai elastic search (sandbox plan on heroku) once added to your pipeline and hooked up to your application does not use port :9200.

If you get to your environment settings , and take a look at the bonzai url, you'll see there is no port on it.

https://medium.com/@thecolorfulcrayon/configuring-elasticsearch-on-rails-8bcbe973e9e7

according to this, by creating a yaml file with the production url, it should work? (testing it now)


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.