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


(Oddo Da) #1

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}]]


(Alexander Reelsen) #2

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


(system) #3

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