Search code examples
ruby-on-railsrubyherokuelasticsearchbonsai-elasticsearch

Skipping index creation, cannot connect to Elasticsearch


I'm having difficulty with connecting my Heroku app to an Elasticsearch instance. I'm using the tire gem and the bonsai add-on on Heroku.

When I deploy the application I get this error twice:

Skipping index creation, cannot connect to Elasticsearch

I also have this in my initialize bonsai.rb file:

if ENV['BONSAI_INDEX_URL']
  bonsai_uri = URI.parse(ENV['BONSAI_INDEX_URL'])
  Tire.configure do
    url "http://sampleindex.bonsai.io"
  end
  BONSAI_INDEX_NAME = bonsai_uri.path[1..-1]
else
  BONSAI_INDEX_NAME = "my_index"
end

Solution

  • Looking like you may be pointing to an invalid ElasticSearch URL. Try typing the following from the command line:

    heroku config | grep BONSAI
    #=> BONSAI_URL     => http://ql9lsrn8:img5ndnsbtaahloy@redwood-94865.us-east-1.bonsai.io/
    

    This should return the operating URL on Heroku's Bonsai service. Use this in your configuration:

    Tire.configure do
      url "http://ql9lsrn8:img5ndnsbtaahloy@redwood-94865.us-east-1.bonsai.io/"
    end