Cannot connect to localhost:9200

Installation:

Raspberry Pi 3+
Raspbian GNU/Linux 9 (stretch)"
===================== Installation ===$ sudo apt-get install elasticsearch
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
coinor-libipopt1v5 libexiv2-14 libmumps-seq-4.10.0 libraw15 netsurf-common realpath wolframscript
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
ant ant-optional antlr groovy ivy java-wrappers junit4 libantlr-java libapache-pom-java libasm-java libbsf-java libbsh-java libcommons-cli-java
libcommons-logging-java libcommons-parent-java libelasticsearch1.7-java libgpars-groovy-java libhamcrest-java libhawtjni-runtime-java libhyperic-sigar-java
libjansi-java libjansi-native-java libjcommander-java libjcsp-java libjline2-java libjna-java libjna-jni libjsr166y-java libjts-java liblog4j-extras1.2-java
liblog4j1.2-java liblucene4.10-java libmultiverse-core-java libnetty-3.9-java libqdox-java libregexp-java libspatial4j-0.4-java libxpp3-java libxstream-java
libyaml-snake-java testng
Suggested packages:
ant-doc ant-gcj ant-optional-gcj javacc junit jython libbcel-java libcommons-net-java libmail-java libjaxp1.3-java libjdepend-java libjsch-java liboro-java
libxalan2-java libxml-commons-resolver1.1-java groovy-doc libjsch-agent-proxy-java libbcprov-java libbcpg-java ivy-doc bsh rhino libavalon-framework-java
libcommons-logging-java-doc libexcalibur-logkit-java libgpars-groovy-java-doc libjcommander-java-doc libjcsp-java-doc libjna-java-doc libjts-java-doc
libgeronimo-jms-1.1-spec-java liblog4j-extras1.2-java-doc liblog4j1.2-java-doc libbcpkix-java libjboss-logging-java libnetty-tcnative-java libprotobuf-java
libslf4j-java libqdox-java-doc libcglib-nodep-java libdom4j-java libjdom1-java libjdom2-java libjettison-java libjoda-time-java libkxml2-java
libwoodstox-java libxom-java
The following NEW packages will be installed:
ant ant-optional antlr elasticsearch groovy ivy java-wrappers junit4 libantlr-java libapache-pom-java libasm-java libbsf-java libbsh-java
libcommons-cli-java libcommons-logging-java libcommons-parent-java libelasticsearch1.7-java libgpars-groovy-java libhamcrest-java libhawtjni-runtime-java
libhyperic-sigar-java libjansi-java libjansi-native-java libjcommander-java libjcsp-java libjline2-java libjna-java libjna-jni libjsr166y-java libjts-java
liblog4j-extras1.2-java liblog4j1.2-java liblucene4.10-java libmultiverse-core-java libnetty-3.9-java libqdox-java libregexp-java libspatial4j-0.4-java
libxpp3-java libxstream-java libyaml-snake-java testng

Preparing to unpack .../32-elasticsearch_1.7.5-1_all.deb ...
Warning: The home dir /var/lib/elasticsearch you specified can't be accessed: No such file or directory
Adding system user elasticsearch' (UID 116) ... Adding new userelasticsearch' (UID 116) with group elasticsearch' ... Not creating home directory/var/lib/elasticsearch'.
Unpacking elasticsearch (1.7.5-1) ...
Setting up libelasticsearch1.7-java (1.7.5-1) ...
Setting up elasticsearch (1.7.5-1) ...

*Completed
============= Problem =============
I went to change /etc/elasticsearch/elasticsearch.yml as the installation instructions say.
All the lines were commented so I uncommented 2 lines:

network.host: 0.0.0.0
http.port: 9200

Elasticsearch is running as a service:

$ sudo service elasticsearch status
● elasticsearch.service - LSB: Starts elasticsearch
Loaded: loaded (/etc/init.d/elasticsearch; generated; vendor preset: enabled)
Active: active (exited) since Tue 2019-05-21 02:53:17 PDT; 2min 52s ago
Docs: man:systemd-sysv-generator(8)
Process: 21421 ExecStop=/etc/init.d/elasticsearch stop (code=exited, status=0/SUCCESS)
Process: 21455 ExecStart=/etc/init.d/elasticsearch start (code=exited, status=0/SUCCESS)

May 21 02:53:17 hera systemd[1]: Starting LSB: Starts elasticsearch...
May 21 02:53:17 hera systemd[1]: Started LSB: Starts elasticsearch.

============= Testing the installation:
$ curl http://localhost:9200
curl: (7) Failed to connect to localhost port 9200: Connection refused

There are no log files:
$ sudo ls -l /var/{log,lib}/elasticsearch
/var/lib/elasticsearch:
total 0

/var/log/elasticsearch:
total 0

What gives here? Why is nothing working properly?
More specifically, why are there no log files?

You can use journalctl to check the system logfile output.

I would highly advise to not run an Elasticsearch version that has been released more than three years ago and is four major versions behind.

--Alex

1 Like

I see. The one being offered by the apt repo is not current?

No, you should definitely use our repos - https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html

Yeah. I tried that. The problem is that I want to run it from a Raspberry Pi3
So I had to do some finagling with the 7.1.0 source, install openjdk10, and set JAVA_HOME to the openjdk.

Now I have it working except for the jna issue, which seems to require obtaining linux_arm.jar

Seeing how that pans out.

This issue:

java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/linux-arm/libjnidispatch.so) not found in resource path

Seems to be caused by the fact that linux-arm version of the library does not exist in jna-4.5.1.jar
Fixed it by obtaining libjna-jni_4.5.2-1_armhf.deb, extracting the library and adding it to jna-4.5.1.jar

============= DEBRIEF
What I did not notice is that the apt system installed Elasticsearch 1.7.5
I was attempting to work on an ancient version,

Also, the packaged jdk was not executable in my environment.

The solution was to get the Elasticsearch 7.1.0 linux tar and install openjdk10. I had considered compiling openjdk 11 from scratch, but I decided to test the install with OJDK 10 and had success in getting things fired up

Set JAVA_HOME to the newer architecture-relevant JDK and I was able to get Elasticsearch working
immediately.

Some minor glitches with JNA Native were also fixed.

THe last bug is seccomp which may be fixable borrowing from an Elasticsearch fork specifically for RPi.

Now to tackle Logstash and Kibana.

2 Likes

wow, you jumped through quite some hoops to get up and running. Thanks for sharing everything in here, much appreciated!

1 Like

Yeah. Bit of a trial, but this is what DevOps looks like I guess.
Wise to have some skills at fixing things when they don't run smoothly.

Hopefully this info helps someone else in some way.

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