{"_id":"5684152b7af9120d007ac3e9","__v":8,"parentDoc":null,"project":"5633ebff7e9e880d00af1a53","version":{"_id":"5633ec007e9e880d00af1a56","project":"5633ebff7e9e880d00af1a53","__v":15,"createdAt":"2015-10-30T22:15:28.105Z","releaseDate":"2015-10-30T22:15:28.105Z","categories":["5633ec007e9e880d00af1a57","5633f072737ea01700ea329d","5637a37d0704070d00f06cf4","5637cf4e7ca5de0d00286aeb","564503082c74cf1900da48b4","564503cb7f1fff210078e70a","567af26cb56bac0d0019d87d","567afeb8802b2b17005ddea0","567aff47802b2b17005ddea1","567b0005802b2b17005ddea3","568adfffcbd4ca0d00aebf7e","56ba80078cf7c9210009673e","574d127f6f075519007da3d0","574fde60aef76a0e00840927","57a22ba6cd51b22d00f623a0"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"564503082c74cf1900da48b4","__v":13,"project":"5633ebff7e9e880d00af1a53","version":"5633ec007e9e880d00af1a56","pages":["564503117f1fff210078e707","564504a8b360ea0d00914852","564504aeb360ea0d00914854","564504b32229d7170010926d","564504bf6b0ca50d00f6bd6b","564504c62c74cf1900da48b9","564504ccd608df0d00d26a21","564504d72c74cf1900da48bb","564504df7f1fff210078e70b","564504e66b0ca50d00f6bd6e","564504ebb360ea0d00914858","568ade3697d8960d0012ab4c","568b2c687a42220d004982bf"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-11-12T21:22:16.300Z","from_sync":false,"order":6,"slug":"troubleshooting-common-errors","title":"Troubleshooting"},"user":"5633ec9b35355017003ca3f2","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-30T17:32:27.467Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"This error most commonly occurs when your Elasticsearch client has not been properly configured. By default, many clients will try to connect to localhost:9200. Since Heroku is not running Elasticsearch (Bonsai is a third party service that maintains the service outside of the Heroku ecosystem), port 9200 is closed and the client responds with “Connection refused.”\n\nThe solution is to ensure that the client is properly configured. If you’re using the [elastisearch-rails client](https://github.com/elasticsearch/elasticsearch-rails), simply add the following gem to your Gemfile and install via Bundler:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"gem 'bonsai-elasticsearch-rails'\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\nAlternatively, you can initialize the client yourself using the Heroku environment variable for your cluster URL:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Elasticsearch::Model.client = Elasticsearch::Client.new url: ENV['BONSAI_URL']\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\nIf you’re using a different client, consult the documentation and ensure that it is configured to connect to your cluster and not localhost:9200.","excerpt":"","slug":"troubleshooting","type":"basic","title":"Connection Refused"}

Connection Refused


This error most commonly occurs when your Elasticsearch client has not been properly configured. By default, many clients will try to connect to localhost:9200. Since Heroku is not running Elasticsearch (Bonsai is a third party service that maintains the service outside of the Heroku ecosystem), port 9200 is closed and the client responds with “Connection refused.” The solution is to ensure that the client is properly configured. If you’re using the [elastisearch-rails client](https://github.com/elasticsearch/elasticsearch-rails), simply add the following gem to your Gemfile and install via Bundler: [block:code] { "codes": [ { "code": "gem 'bonsai-elasticsearch-rails'", "language": "ruby" } ] } [/block] Alternatively, you can initialize the client yourself using the Heroku environment variable for your cluster URL: [block:code] { "codes": [ { "code": "Elasticsearch::Model.client = Elasticsearch::Client.new url: ENV['BONSAI_URL']", "language": "ruby" } ] } [/block] If you’re using a different client, consult the documentation and ensure that it is configured to connect to your cluster and not localhost:9200.