Faraday::Connectionfailed, Connection Refused - Connect(2) for "Localhost" Port 9200 Error Ruby on Rails

Faraday::ConnectionFailed, Connection refused - connect(2) for “localhost” port 9200 Error Ruby on Rails

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

Looks like your elastic search service is not running. You have to make sure it's running.

To see if your elastic search service is running, run:

curl localhost:9200

If it's running, then it should return a hash like this:

{
"status" : 200,
"name" : "Buzz",
"cluster_name" : "your_cluster_name",
"version" : {
"number" : "1.4.5",
"build_hash" : "...",
"build_timestamp" : "2015-04-27T08:06:06Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}

If elastic search is not running which is most likely the case for you, start it using this command:

sudo service elasticsearch start

That should fix your problem.

Faraday::ConnectionFailed Connection refused - connect(2) for localhost port 9200

It's probably because your Elasticsearch server doesn't start automatically when you boot your PC.

If you install your Elasticsearch server as a service and configure it properly, the problem will go away.

Faraday::ConnectionFailed, Connection refused - connect(2) for localhost port 9200

For all those who find this and might be wondering how to restart the elasticsearch plugin:

/etc/init.d/elasticsearch restart

worked for me.

Faraday::ConnectionFailed in Devise::SessionsController#create

when you run elasticsearch you get the following error

ERROR: Cluster name [elasticsearch_etiennelandro] subdirectory exists in data paths [/usr/local/var/lib/elasticsearch/elasticsearch_etiennelandro]. All data under these paths must be moved up one directory to paths [/usr/local/var/lib/elasticsearch]

as explained from xeraa in this post

Did you have an older version (2.x or before) installed before? It sounds a lot like this PR to check that you're not using the old behavior when there was the node name in the path.

What I would do:

  • If you don't need the data any more, just remove
    /usr/local/var/lib/elasticsearch/elasticsearch_nikitavlasenko and
    start fresh.

  • If you need the data, you could either change path.data in your
    config or move the folder one level up (just like the log message
    says).


PS: I wouldn't use port 9300 for HTTP, because that's generally the port used for communication of the nodes in a cluster itself.

also consider reading their comments and relevant posts from that page, for example the one from Franz Kafka

Turns out that the config file points to /usr/local/var/lib/elasticsearch for the data path, but the package creates the directory /usr/local/var/lib/elasticsearch/elasticsearch_USERNAME. Since that elasticsearch_USERNAME directory is in there, it fails to start. I resolved the error by simply removing the elasticsearch_USERNAME directory as you suggested.

The error crashes your elastichsearch server which should be running on localhost:9200

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

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



Related Topics



Leave a reply



Submit