user2857014
user2857014

Reputation: 577

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.

Upvotes: 5

Views: 11914

Answers (1)

Laurens
Laurens

Reputation: 2420

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

Upvotes: 12

Related Questions