# Cannot connect to localhost:9200

**URL:** <https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974>\
**Category:** Elasticsearch\
**Created:** [May 21, 2019, 10:05am UTC](https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974 "2019-05-21T10:05:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingram](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@kingram](https://discuss.elastic.co/u/kingram)\
**Post date:** [May 21, 2019, 10:05am UTC](https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974/1 "2019-05-21T10:05:56Z")

</div>

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 user`elasticsearch' (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](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?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 22, 2019, 8:12am UTC](https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974/2 "2019-05-22T08:12:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kingram](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@kingram](https://discuss.elastic.co/u/kingram)\
**Post date:** [May 22, 2019, 7:01pm UTC](https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974/3 "2019-05-22T19:01:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 23, 2019, 12:00am UTC](https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974/4 "2019-05-23T00:00:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kingram](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@kingram](https://discuss.elastic.co/u/kingram)\
**Post date:** [May 23, 2019, 1:07am UTC](https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974/5 "2019-05-23T01:07:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kingram](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@kingram](https://discuss.elastic.co/u/kingram)\
**Post date:** [May 23, 2019, 2:36am UTC](https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974/6 "2019-05-23T02:36:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kingram](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@kingram](https://discuss.elastic.co/u/kingram)\
**Post date:** [May 23, 2019, 2:44am UTC](https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974/7 "2019-05-23T02:44:53Z")

</div>

============= 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.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 23, 2019, 1:01pm UTC](https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974/8 "2019-05-23T13:01:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kingram](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@kingram](https://discuss.elastic.co/u/kingram)\
**Post date:** [May 23, 2019, 8:24pm UTC](https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974/9 "2019-05-23T20:24:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 20, 2019, 8:24pm UTC](https://discuss.elastic.co/t/cannot-connect-to-localhost-9200/181974/10 "2019-06-20T20:24:42Z")

</div>

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