Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch error failed to connect to master - no route to host

When I run elasticsearch 0.90.0 with command: bin/elasticsearch -f, I get this error:

[2014-09-17 15:00:27,998][INFO ][node                     ] [Myers, Fred] {0.90.0}[8030]: initializing ...
[2014-09-17 15:00:28,005][INFO ][plugins                  ] [Myers, Fred] loaded [], sites []
[2014-09-17 15:00:30,508][INFO ][node                     ] [Myers, Fred] {0.90.0}[8030]: initialized
[2014-09-17 15:00:30,508][INFO ][node                     ] [Myers, Fred] {0.90.0}[8030]: starting ...
[2014-09-17 15:00:30,762][INFO ][transport                ] [Myers, Fred] bound_address {inet[/0:0:0:0:0:0:0:0:9301]}, publish_address {inet[/192.168.0.108:9301]}
[2014-09-17 15:00:36,874][WARN ][discovery.zen            ] [Myers, Fred] failed to connect to master [[Holly][nlr9o-yfSQ6MsTtYlTlqlw][inet[/192.168.1.6:9300]]], retrying...
org.elasticsearch.transport.ConnectTransportException: [Holly][inet[/192.168.1.6:9300]] connect_timeout[30s]
    at org.elasticsearch.transport.netty.NettyTransport.connectToChannels(NettyTransport.java:671)
    at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:610)
    at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:580)
    at org.elasticsearch.transport.TransportService.connectToNode(TransportService.java:127)
    at org.elasticsearch.discovery.zen.ZenDiscovery.innterJoinCluster(ZenDiscovery.java:337)
    at org.elasticsearch.discovery.zen.ZenDiscovery.access$500(ZenDiscovery.java:76)
    at org.elasticsearch.discovery.zen.ZenDiscovery$1.run(ZenDiscovery.java:290)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.NoRouteToHostException: No route to host
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:150)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79)
    at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:312)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42)
    at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
    at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    ... 3 more
[2014-09-17 15:00:36,874][WARN ][transport.netty          ] [Myers, Fred] exception caught on transport layer [[id: 0x361eaf47]], closing connection
java.net.NoRouteToHostException: No route to host
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:150)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79)
    at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:312)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42)
    at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108)
    at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
[2014-09-17 15:00:42,892][WARN ][transport.netty          ] [Myers, Fred] exception caught on transport layer [[id: 0x2656abc9]], closing connection
java.net.NoRouteToHostException: No route to host
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:150)
    at org.elasticsearch.common.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105)
...

I don't install logstash. When I access localhost:9200, I get

{
  ok: true,
  status: 503,
  name: "Haywire",
  version: {
    number: "0.90.0",
    snapshot_build: false
  },
  tagline: "You Know, for Search"
}

Can anyone help me solve this problem?

like image 938
Cao Văn An Avatar asked Sep 17 '14 08:09

Cao Văn An


2 Answers

Your ElasticSearch instance is trying to join a cluster (probably someone else on your network) but fails. You should disable automatic cluster discovery.

  1. Find the 'Discovery' section in /etc/elasticsearch/elasticsearch.yml

  2. Disable multicast discovery (enabled by default) by uncommenting this line:

# discovery.zen.ping.multicast.enabled: false

EDIT: I just discovered that this error can still happen, even when "zen multicast discovery" is disabled. If (like me) you have network.bind_host: 127.0.0.1 in elasticsearch.yml (to only allow local connections to ElasticSearch), you must also set network.host: 127.0.0.1. Otherwise, ElasticSearch will not be able to connect to itself (it needs to, for some reason).

like image 176
david_p Avatar answered Nov 17 '22 15:11

david_p


Give a name to your cluster and the issue will be solved.

Edit config/elasticsearch.yml in your elasticsearch directory.

Uncomment cluster.name: elasticsearch and change it to something like cluster.name: your_hostname

Then try to start elasticsearch again.

like image 33
Harikrishnan Avatar answered Nov 17 '22 15:11

Harikrishnan