Searckick + Elastick Search Failed to connect to localhost:9200

My application was working fine until a few minutes ago, I get the following error:

Faraday::ConnectionFailed in Devise::SessionsController#create
Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200)

I tried searching and found this might be related to elastic search. So I did the following:

$ curl localhost:9200
curl: (7) Failed to connect to localhost port 9200: Connection refused

$ brew services start elasticsearch
Service `elasticsearch` already started, use `brew services restart elasticsearch` to restart.

Nothing has changed, it still not working.

I guess there could be multiple sources for the problem. Does anybody knows how to investigate and fix this one please? The rest of the app works well, but everything that has to do with searchkick in the model, creates that issue.

Below is the log from console:

Processing by Devise::SessionsController#destroy as HTML
Parameters: {"authenticity_token"=>"uaT1nvIHefWongRLepHPoXy5h5gihEh+0ymBaujsenamdkis/lRiB2Yhnsbnr6xkmDPRwJDURXvV9NSm8A==", "locale"=>"en"}
User Load (0.5ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", "2c99733a-4ae0-42f8-97ba-9e4287d7c1cf"], ["LIMIT", 1]]
(0.2ms)  BEGIN
           ActsAsTaggableOn::Tagging Load (0.4ms)  SELECT "taggings".* FROM "taggings" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2  [["taggable_id", 2], ["taggable_type", "User"]]
           (0.2ms)  COMMIT

User Store (7.1ms)  {"id":"2c99893a-4ae0-47f8-97ba-9e4487d7c1cf","exception":["Faraday::ConnectionFailed","Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for \"localhost\" port 9200)"],"exception_object":"Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for \"localhost\" port 9200)"}
Completed 500 Internal Server Error in 16ms (Searchkick: 7.1ms | ActiveRecord: 1.2ms)



Faraday::ConnectionFailed (Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200)):
I just tried reindexing a table :

2.5.3 :001 > Event.reindex
Traceback (most recent call last):
1: from (irb):1
Faraday::ConnectionFailed (Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200))




$ elasticsearch
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file logs/gc.log due to No such file or directory

[2019-05-07T11:41:56,649][WARN ][o.e.c.l.LogConfigurator ] [unknown] Some logging configurations have %marker but don't have %node_name. We will automatically add %node_name to the pattern to ease the migration for users who customize log4j2.properties but will stop this behavior in 7.0. You should manually replace %node_name with [%node_name]%marker in these locations:
/usr/local/etc/elasticsearch/log4j2.properties
[2019-05-07T11:41:57,948][INFO ][o.e.e.NodeEnvironment ] [Uqr3VHG] using [1] data paths, mounts [[/ (/dev/disk1)]], net usable_space [386.7gb], net total_space [464.6gb], types [hfs]
[2019-05-07T11:41:57,948][INFO ][o.e.e.NodeEnvironment ] [Uqr3VHG] heap size [990.7mb], compressed ordinary object pointers [true]
[2019-05-07T11:41:58,748][INFO ][o.e.n.Node ] [Uqr3VHG] node name derived from node ID [Uqr3VHGpQTmcyJav-f-6RQ]; set [node.name] to override
[2019-05-07T11:41:58,748][INFO ][o.e.n.Node ] [Uqr3VHG] version[6.7.0], pid[29217], build[oss/tar/8453f77/2019-03-21T15:32:29.844721Z], OS[Mac OS X/10.13.6/x86_64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_192/25.192-b12]
[2019-05-07T11:41:58,749][INFO ][o.e.n.Node ] [Uqr3VHG] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/var/folders/c_/cqbnlqbx5lq7vjgf31_wsgvh0000gp/T/elasticsearch-6333526767767413674, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/usr/local/Cellar/elasticsearch/6.7.0/libexec, -Des.path.conf=/usr/local/etc/elasticsearch, -Des.distribution.flavor=oss, -Des.distribution.type=tar]
[2019-05-07T11:42:01,279][INFO ][o.e.p.PluginsService ] [Uqr3VHG] loaded module [aggs-matrix-stats]
[2019-05-07T11:42:01,280][INFO ][o.e.p.PluginsService ] [Uqr3VHG] loaded module [analysis-common]
[2019-05-07T11:42:01,280][INFO ][o.e.p.PluginsService ] [Uqr3VHG] loaded module [ingest-common]
[2019-05-07T11:42:01,280][INFO ][o.e.p.PluginsService ] [Uqr3VHG] loaded module [ingest-geoip]
[2019-05-07T11:42:01,280][INFO ][o.e.p.PluginsService ] [Uqr3VHG] loaded module [ingest-user-agent]
[2019-05-07T11:42:01,280][INFO ][o.e.p.PluginsService ] [Uqr3VHG] loaded module [lang-expression]
[2019-05-07T11:42:01,280][INFO ][o.e.p.PluginsService ] [Uqr3VHG] loaded module [lang-mustache]
[2019-05-07T11:42:01,281][INFO ][o.e.p.PluginsService ] [Uqr3VHG] loaded module [lang-painless]
[2019-05-07T11:42:01,281][INFO ][o.e.p.PluginsService ] [Uqr3VHG] loaded module [mapper-
[2019-05-07T11:42:01,282][INFO ][o.e.p.PluginsService ] [Uqr3VHG] loaded module [transport-netty4]
[2019-05-07T11:42:01,282][INFO ][o.e.p.PluginsService ] [Uqr3VHG] loaded module [tribe]
[2019-05-07T11:42:01,283][INFO ][o.e.p.PluginsService ] [Uqr3VHG] no plugins loaded
[2019-05-07T11:42:08,927][INFO ][o.e.d.DiscoveryModule ] [Uqr3VHG] using discovery type [zen] and host providers [settings]
[2019-05-07T11:42:09,753][INFO ][o.e.n.Node ] [Uqr3VHG] initialized
[2019-05-07T11:42:09,753][INFO ][o.e.n.Node ] [Uqr3VHG] starting ...
[2019-05-07T11:42:10,495][INFO ][o.e.t.TransportService ] [Uqr3VHG] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
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]
[2019-05-07T11:42:10,561][INFO ][o.e.n.Node ] [Uqr3VHG] stopping ...
[2019-05-07T11:42:10,589][INFO ][o.e.n.Node ] [Uqr3VHG] stopped
[2019-05-07T11:42:10,590][INFO ][o.e.n.Node ] [Uqr3VHG] closing ...
[2019-05-07T11:42:10,614][INFO ][o.e.n.Node ] [Uqr3VHG] closed

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.