Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection refused - connect(2) for "localhost" port 9200 with DigitalOcean

I am using DigitalOcean for my Ruby on Rails app with Elasticsearch. So I am getting

Faraday::ConnectionFailed in PetsController#create
Connection refused - connect(2) for "localhost" port 9200

I am wondering if it is because I am not using localhost on DigitalOcean. I am guessing if I have to change it in my app to start listening to the ip address I am using for DigitalOcean, but am not sure where I should look at.

like image 412
user2857014 Avatar asked Dec 18 '15 07:12

user2857014


1 Answers

Can you check the following on digitalocean:

sudo vi /etc/elasticsearch/elasticsearch.yml

Look for:

network.bind_host: localhost

source: https://www.digitalocean.com/community/tutorials/how-to-install-elasticsearch-on-an-ubuntu-vps

also, are you sure elasticsearch is running? The following command should give you a hash as result:

curl localhost:9200

If not: try to start it and try again:

sudo service elasticsearch start

Also, you'll probably want to boot elasticsearch automatically like described here https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-service.html

like image 69
Laurens Avatar answered Sep 30 '22 10:09

Laurens