Elasticsearch connection refused

elasticsearch

I have just installed ElasticSearch 7.1.1 on Debian 9 throw apt-get repository
VPS 4GB ram .. 1vcpu

service elasticsearch status

 elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2019-06-04 16:53:25 CEST; 4min 53s ago
     Docs: http://www.elastic.co
  Process: 3161 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=78)
 Main PID: 3161 (code=exited, status=78)

Jun 04 16:53:11 MONITOR-BACKUP systemd[1]: Started Elasticsearch.
Jun 04 16:53:11 MONITOR-BACKUP elasticsearch[3161]: OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Jun 04 16:53:25 MONITOR-BACKUP systemd[1]: elasticsearch.service: Main process exited, code=exited, status=78/n/a
Jun 04 16:53:25 MONITOR-BACKUP systemd[1]: elasticsearch.service: Unit entered failed state.
Jun 04 16:53:25 MONITOR-BACKUP systemd[1]: elasticsearch.service: Failed with result 'exit-code'.

test curl

curl -X GET http://159.69.195.123:9200/
curl: (7) Failed to connect to 159.69.195.123 port 9200: Connection refused

enviroment vars

$PATH
-bash: /usr/share/elasticsearch/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: No such file or directory

$JAVA_HOME
-bash: /usr/share/elasticsearch/jdk: Is a directory

Best Answer

In my case, status=78, it was solved by keeping node.name and cluster.initial_master_nodes with a proper name.

 elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-08-07 19:55:30 EEST; 3s ago
     Docs: http://www.elastic.co
  Process: 2331 ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet (code=exited, status=78)
 Main PID: 2331 (code=exited, status=78)

I read that due to the changes in cluster coordination introduced in Elasticsearch 7.x (https://www.elastic.co/blog/a-new-era-for-cluster-coordination-in-elasticsearch), as the log shows we are forced to configure at least one of those mentioned parameters in production.

In this case it can be easily solved by adding this to your elasticsearch.yml:

node.name: node-1 (or preferred name)

cluster.initial_master_nodes: node-1 (or preferred name)

This is also mentioned in the breaking changes 7.0 documentation of Elasticsearch (https://www.elastic.co/guide/en/elasticsearch/reference/7.0/breaking-changes-7.0.html#_discovery_configuration_is_required_in_production).

Source: https://groups.google.com/forum/#!topic/wazuh/MTNx6RcqRcQ