1

I'm trying to run Elasticsearch on Heorku with the Bonsai add on but I keep getting the following error:

Faraday::ConnectionFailed (Connection refused - connect(2)):

and then this sometimes too

Completed 500 Internal Server Error in 131ms (Searchkick: 5.7ms | ActiveRecord: 11.1ms)
Faraday::ConnectionFailed (Connection refused - connect(2)):

I've heard this is because it can't find the Bonsai URL but I believe i initiated that with /config/initializer/bonsai.rb

Elasticsearch::Model.client = Elasticsearch::Client.new url: ENV['BONSAI_URL']

Any ideas? Basically the whole app has stopped working. It runs fine locally this is just on production.

I also have gem 'bonsai-elasticsearch-rails', '~> 0.0.4' installed but still not working.

I also went and re built the index, according to this and still the same error

    rs191919:~/workspace/sample_app (bonsai-more-more) $ curl -XPOST [MYURL]/pallet-index
    {"acknowledged":true}
rs191919:~/workspace/sample_app (bonsai-more-more) $ curl -XPOST [MYURL]/hello -d '{"title":"Hello world"}'
    {"_index":"pallet-index","_type":"test","_id":"hello","_version":1,"created":true}
rs191919:~/workspace/sample_app (bonsai-more-more) $ curl -XGET '[MYURL]/pallet-index/te 
    {"_index":"pallet-index","_type":"test","_id":"hello","_version":1,"found":true,"_source":{"title":"Hello world"}} 
rs19
  • 657
  • 1
  • 10
  • 22
  • 1
    Can you try to run this before starting your process: `export BONSAI_URL=$(heroku config:get BONSAI)` You somehow need to set the `BONSAI_URL` env variable in order to be able to use it in your code. – Val Mar 07 '16 at 15:53
  • @Val where/when should i run that? sorry super new to this all. – rs19 Mar 07 '16 at 15:55
  • On the same machine where you run your client code. – Val Mar 07 '16 at 15:59
  • @Val ok i did that and still getting the same error. – rs19 Mar 07 '16 at 16:01
  • What do you get if you run `curl -XGET $(heroku config:get BONSAI)` in your shell? – Val Mar 07 '16 at 16:06
  • @Val `rs191919:~/workspace/sample_app (bonsai-more-more) $ curl -XGET $(heroku config:get BONSAI) curl: no URL specified! curl: try 'curl --help' or 'curl --manual' for more information rs191919:~/workspace/sample_app (bonsai-more-more) $ ` – rs19 Mar 07 '16 at 16:07
  • 1
    woops, my bad, `curl -XGET $(heroku config:get BONSAI_URL)` (missed the `_URL` suffix). Please try again. – Val Mar 07 '16 at 16:10
  • @Val no worries! appreciate your help with all of this. `rs191919:~/workspace/sample_app (bonsai-more-more) $ curl -XGET $(heroku config:get BONSAI_URL) { "status" : 200, "name" : "Link", "cluster_name" : "elasticsearch", "version" : { "number" : "1.7.2", "build_hash" : "[MYHASH}", "build_timestamp" : "2015-09-29T22:19:18Z", "build_snapshot" : false, "lucene_version" : "4.10.4" }, "tagline" : "You Know, for Search" }` – rs19 Mar 07 '16 at 16:11
  • 1
    Much better! Now make sure that `BONSAI_URL` gets set and exported in the shell where you start your client application as shown in my first comment above. – Val Mar 07 '16 at 16:12
  • @Val ok so just to confirm. 1) run `export BONSAI_URL=$(heroku config:get BONSAI)` 2) re push to heroku? unsure what to do after step 1 – rs19 Mar 07 '16 at 16:13
  • Run `export BONSAI_URL=$(heroku config:get BONSAI_URL)` but on the same host as your Ruby code runs. – Val Mar 07 '16 at 16:14
  • @Val sorry my terminology is limited here. in the heroku shell? just unsure where to run that. – rs19 Mar 07 '16 at 16:15
  • Where does your Ruby code run? – Val Mar 07 '16 at 16:17
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/105579/discussion-between-rs19-and-val). – rs19 Mar 07 '16 at 16:17

0 Answers0