# Cannot connect to elasticsearch cluster when it runs as a system service, works if I run it as me

**URL:** <https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-when-it-runs-as-a-system-service-works-if-i-run-it-as-me/155166>\
**Category:** Elasticsearch\
**Created:** [November 2, 2018, 12:11pm UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-when-it-runs-as-a-system-service-works-if-i-run-it-as-me/155166 "2018-11-02T12:11:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oddo\_Da](https://avatars.discourse-cdn.com/v4/letter/o/4491bb/32.png) [@Oddo\_Da](https://discuss.elastic.co/u/Oddo_Da)\
**Post date:** [November 2, 2018, 12:11pm UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-when-it-runs-as-a-system-service-works-if-i-run-it-as-me/155166/1 "2018-11-02T12:11:28Z")

</div>

Hello, I have a centos machine where I can run elasticsearch as a service (via systemctl). My elasticsearch.yml states that network.host, transport.host, http.host all be 0.0.0.0. However, when I try to run basic code using the Java JDK connecting to 9300 (via transport client), it fails with the error message below. However, if I run elasticsearch-6.4.2/bin/elasticsearch with the same elasticsearch.yml file, my code can connect just fine. I can also telnet localhost 9300 in both instances. sudo netstat -lp -n gives the following output:  
tcp 0 0 0.0.0.0:9200 0.0.0.0:\* LISTEN 396429/java  
tcp 0 0 0.0.0.0:9300 0.0.0.0:\* LISTEN 396429/java

I am connecting from Scala code using the java jdk as in:

private val esclient:TransportClient = new PreBuiltTransportClient(Settings.EMPTY).  
addTransportAddress(new TransportAddress(InetAddress.getByName(host),port)) where host="localhost" and port=9300

What gives? This is driving me crazy!

[error] (run-main-0) NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{ZcfR\_a69ROSL2mkumjJUAQ}{10.250.124.183}{127.0.0.1:9300}]]  
[error] NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{ZcfR\_a69ROSL2mkumjJUAQ}{10.250.124.183}{127.0.0.1:9300}]]

---

<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:** [November 6, 2018, 9:17am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-when-it-runs-as-a-system-service-works-if-i-run-it-as-me/155166/2 "2018-11-06T09:17:58Z")

</div>

please format you snippets properly using markdown, as it will be much better to read.

If you use a different cluster name than elasticsearch, you have to configure this in the settings in the constructor of the transport client.

--Alex

---

<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:** [December 4, 2018, 9:18am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-when-it-runs-as-a-system-service-works-if-i-run-it-as-me/155166/3 "2018-12-04T09:18:02Z")

</div>

Closed on December 4, 2018, 9:18am UTC

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