Curl: (7) Failed connect to localhost:9200;

Hello, I'm new here, and not too skilled with programming/setting up tools on servers either.
I'm trying to install ElasticSearch on my CentOS7 server.

I followed the istructions from this website, exactly as they are written, and everything seemed to work fine, until I made a connection test with the curl -X GET command and the :9200 port.

I added some parameters I found on this other tutorial.

Here is my etc/elasticsearch/elasticsearch.yml configuration file.

And this is what I get when I try to restart and do a connection test to the port :9200

[root@localhost elasticsearch]# sudo service elasticsearch restart
Restarting elasticsearch (via systemctl):                         [OK ]
[root@localhost elasticsearch]# curl -X GET 'http://localhost:9200'
curl: (7) Failed connect to localhost:9200; Connessione rifiutata
[root@localhostelasticsearch]#

And what I set for the firewall, using the local IP address of the server.

sudo firewall-cmd --new-zone=elasticsearch --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --zone=elasticsearch --add-source=10.150.2.3 --permanent
sudo firewall-cmd --zone=elasticsearch --add-port=9200/tcp --permanent
sudo firewall-cmd --reload

Any idea about what could be wrong? Thanks in advance!

Can you share elasticsearch logs please?

Please don't post images of text as they are hardly readable and not searchable.

Instead paste the text and format it with </> icon. Check the preview window.

I will...

I found the folder containing the logs, which ones do you need?

There is a list of them.

[root@localhost elasticsearch]# ls
elasticsearch_access.log                  my-application_access.log
elasticsearch_audit.log                   my-application_audit.log
elasticsearch_deprecation.log             my-application_deprecation.log
elasticsearch_index_indexing_slowlog.log  my-application_index_indexing_slowlog.log
elasticsearch_index_search_slowlog.log    my-application_index_search_slowlog.log
elasticsearch.log                         my-application.log
gc.log.0.current

elasticsearch.log

Alright!

Sadly, I can't share it all here because of the characters limit... so here is a pastebin.

Could you run:

curl 10.150.2.3:9200
[genomica@localhost ~]$ sudo systemctl enable elasticsearch.service
[genomica@localhost ~]$ sudo systemctl start elasticsearch.service
[genomica@localhost ~]$ sudo systemctl restart elasticsearch
[genomica@localhost ~]$ curl 10.150.2.3:9200
curl: (7) Failed connect to 10.150.2.3:9200; Connessione rifiutata
[genomica@localhost ~]$

Could it be anything firewall related?

May be.
What are the last logs?

They didn't seem to have changed since yesterday (the last editing date is yesterday, indeed), but I'm attaching them anyways:

There is also a gc.log.0.current file which seems to have been edited today and I'm attaching too.

So the logs are:

[2019-05-21T16:37:31,416][INFO ][o.e.e.NodeEnvironment    ] [lYWaGy6] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [38.2gb], net total_space [49.9gb], types [rootfs]
[2019-05-21T16:37:31,420][INFO ][o.e.e.NodeEnvironment    ] [lYWaGy6] heap size [989.8mb], compressed ordinary object pointers [true]
[2019-05-21T16:37:31,430][INFO ][o.e.n.Node               ] [lYWaGy6] node name derived from node ID [lYWaGy6oQsaEQcgAyxSFFw]; set [node.name] to override
[2019-05-21T16:37:31,430][INFO ][o.e.n.Node               ] [lYWaGy6] version[6.8.0], pid[90851], build[default/rpm/65b6179/2019-05-15T20:06:13.172855Z], OS[Linux/3.10.0-957.10.1.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_212/25.212-b04]
[2019-05-21T16:37:31,430][INFO ][o.e.n.Node               ] [lYWaGy6] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -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=/tmp/elasticsearch-4704341660773096082, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=/var/lib/elasticsearch, -XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:/var/log/elasticsearch/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/etc/elasticsearch, -Des.distribution.flavor=default, -Des.distribution.type=rpm]
...
[2019-05-21T16:37:35,951][INFO ][o.e.x.s.a.s.FileRolesStore] [lYWaGy6] parsed [0] roles from file [/etc/elasticsearch/roles.yml]
[2019-05-21T16:37:36,592][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [lYWaGy6] [controller/91239] [Main.cc@109] controller (64 bit): Version 6.8.0 (Build e6cf25e2acc5ec) Copyright (c) 2019 Elasticsearch BV
[2019-05-21T16:37:37,030][DEBUG][o.e.a.ActionModule       ] [lYWaGy6] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2019-05-21T16:37:37,227][INFO ][o.e.d.DiscoveryModule    ] [lYWaGy6] using discovery type [zen] and host providers [settings]
[2019-05-21T16:37:37,946][INFO ][o.e.n.Node               ] [lYWaGy6] initialized
[2019-05-21T16:37:37,947][INFO ][o.e.n.Node               ] [lYWaGy6] starting ...
[2019-05-21T16:37:38,107][INFO ][o.e.t.TransportService   ] [lYWaGy6] publish_address {10.150.2.3:9300}, bound_addresses {[::]:9300}
[2019-05-21T16:37:38,128][INFO ][o.e.b.BootstrapChecks    ] [lYWaGy6] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2019-05-21T16:37:41,221][INFO ][o.e.c.s.MasterService    ] [lYWaGy6] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {lYWaGy6}{lYWaGy6oQsaEQcgAyxSFFw}{QirsHidvTIabVaH82WLuww}{10.150.2.3}{10.150.2.3:9300}{ml.machine_memory=269954039808, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}
[2019-05-21T16:37:41,240][INFO ][o.e.c.s.ClusterApplierService] [lYWaGy6] new_master {lYWaGy6}{lYWaGy6oQsaEQcgAyxSFFw}{QirsHidvTIabVaH82WLuww}{10.150.2.3}{10.150.2.3:9300}{ml.machine_memory=269954039808, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}, reason: apply cluster state (from master [master {lYWaGy6}{lYWaGy6oQsaEQcgAyxSFFw}{QirsHidvTIabVaH82WLuww}{10.150.2.3}{10.150.2.3:9300}{ml.machine_memory=269954039808, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2019-05-21T16:37:41,321][INFO ][o.e.h.n.Netty4HttpServerTransport] [lYWaGy6] publish_address {10.150.2.3:9200}, bound_addresses {[::]:9200}
[2019-05-21T16:37:41,322][INFO ][o.e.n.Node               ] [lYWaGy6] started
[2019-05-21T16:37:41,652][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [lYWaGy6] Failed to clear cache for realms [[]]
[2019-05-21T16:37:41,697][INFO ][o.e.l.LicenseService     ] [lYWaGy6] license [b0e46bca-dda0-4aea-af32-10693aab36f0] mode [basic] - valid
[2019-05-21T16:37:41,704][INFO ][o.e.g.GatewayService     ] [lYWaGy6] recovered [1] indices into cluster_state
[2019-05-21T16:37:42,113][INFO ][o.e.c.r.a.AllocationService] [lYWaGy6] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[gene][1]] ...]).
[2019-05-21T16:47:35,397][INFO ][o.e.n.Node               ] [lYWaGy6] stopping ...
[2019-05-21T16:47:35,480][INFO ][o.e.x.w.WatcherService   ] [lYWaGy6] stopping watch service, reason [shutdown initiated]
[2019-05-21T16:47:35,908][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [lYWaGy6] [controller/91239] [Main.cc@148] Ml controller exiting
[2019-05-21T16:47:35,909][INFO ][o.e.x.m.p.NativeController] [lYWaGy6] Native controller process has stopped - no new native processes can be started
[2019-05-21T16:47:35,999][INFO ][o.e.n.Node               ] [lYWaGy6] stopped
[2019-05-21T16:47:35,999][INFO ][o.e.n.Node               ] [lYWaGy6] closing ...
[2019-05-21T16:47:36,015][INFO ][o.e.n.Node               ] [lYWaGy6] closed

Something at 2019-05-21T16:47:35,397 is closing your node:

[2019-05-21T16:47:35,397][INFO ][o.e.n.Node               ] [lYWaGy6] stopping ...

Any idea why this is happening?

Sadly, not. I don't have any clue.
I have uninstalled elasticsearch and now retrying everything from the beginning!

yum remove elasticsearch

I was wondering whether some of the parameters I added in my elasticsearch.yml may confuse ElasticSearch somehow...
More specificially, one of those, which are my active ones in my elasticsearch.yml file:

cluster.name: my-application
node.name: node-1
node.attr.rack: r1
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
 network.host: 0.0.0.0
 index.number_of_shards: 1
index.number_of_replicas: 0
node.data: false
 node.master: false
script.disable_dynamic: true

If it may provide any additional information, an informatician friend suggested me to try some 'diagnostic' commands, whose output I may add here.

systemctl status

systemctl --failed

sudo service elasticsearch status

A little update... I have reinstalled it (skipping the firewall configuaration part) and only setting in my .yml file:

network.host: localhost

I skipped completely the firewall setting part.
Now it does seem to work and connect without problems!

If I type:

GET 'http://localhost:9200'

I get:

{
  "name" : "lYWaGy6",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "_na_",
  "version" : {
    "number" : "6.8.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "65b6179",
    "build_date" : "2019-05-15T20:06:13.172855Z",
    "build_snapshot" : false,
    "lucene_version" : "7.7.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

If I type:

sudo service elasticsearch status

Everything seems to be working fine!

[root@localhost data]# sudo service elasticsearch status
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: disabled)
   Active: active (running) since gio 2019-05-23 10:49:37 CEST; 4min 9s ago
     Docs: http://www.elastic.co
 Main PID: 49843 (java)
    Tasks: 350
   CGroup: /system.slice/elasticsearch.service
           ├─49843 /bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.n...
           └─50232 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller

mag 23 10:49:37 localhost.localdomain systemd[1]: Started Elasticsearch.

Those are my new logs:

Any suggestions or it is working properly as it looks like now?

It looks good I guess.

1 Like

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