Elastic Search - Connection Refused when tried to access from different System

I have installed elastic 2.2 on an Ubuntu 14.04. I left the default initial settings of elastic and the elastic instance was reachable form this system at localhost:9200.

Now when I tried via a different system using the IP/DNS name of the server as:

curl -XGET "http://<IP_ADDRESS_UBUNTU_SERVER>:9200"

I get an error as :

Failed to connect to <IP_ADDRESS_UBUNTU_SERVER> port 9200: Connection refused

I tried changing few parameters in elasticsearch.yml file and set it as:

network.host: 0.0.0.0
http.port: 9200

But this did not solve the issue. I set get the same error as connection refused. In-fact setting the above parameters and trying to access from the server using localhost:9200 also gave a connection timed-out error.

Now what is the configuration, I need to set so that this elastic instance is accessible from outside?

I tried to set the IP Address of the Ubuntu server as network.host, but I see the following errors in the log files:

BindTransportException[Failed to bind to [9300-9400]]; nested: ChannelException[Failed to bind to: /10.173.1.176:9400]; nested: BindException[Cannot assign requested address];
at org.elasticsearch.transport.netty.NettyTransport.bindToPort(NettyTransport.java:477)
at org.elasticsearch.transport.netty.NettyTransport.bindServerBootstrap(NettyTransport.java:439)
at org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:320)
at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68)
at org.elasticsearch.transport.TransportService.doStart(TransportService.java:170)
at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68)
at org.elasticsearch.node.Node.start(Node.java:252)
at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:221)

Caused by: java.net.BindException: Cannot assign requested address
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.jboss.netty.channel.socket.nio.NioServerBoss$RegisterTask.run(NioServerBoss.java:193)

To rule out if there is any issue with my server , I hosted a simple page using python server on some random port. I was able to access this page from outside my server with the specified port. So I think this might be an issue with the elastic configurations

Any clue what is happening here?

Can you show us the entire config?

Please update if u find the solution for this error, even i am also facing the same error.

Entire Config:
cluster.name: demousecase
node.name: "dev_node"
network.host: 0.0.0.0
http.port: 9200

You probably want to take a read of https://www.elastic.co/guide/en/elasticsearch/reference/2.2/modules-network.html#network-interface-values

Hi Mark,

I tried all these settings. If I leave the configuration network.* & http.* settings to default, I can see in the elastic log during the start of elasticsearch:

[INFO ][transport ] [dev_node] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}

Also, after this, I can see in netstat -l -n, a 9200 listening port as ( but only accessibly from local system) :

tcp 0 0 127.0.0.1:9200 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9300 0.0.0.0:* LISTEN

But if i set any values for *.host/publish_host/bind_host, I see that the port is not available for listening (as seen in netstat ), neither from localhost nor from outside. A curl on localhost results in connection refused..

What is it, that I am missing?

Thanks
Kiran

What are you actually setting, providing the actual changes really helps us help you.

This was caused due to an error in the config file. I did not adhere to the YAML guidelines and was blindly following the elastic help doc..

The network and the port has to be specified in the YML format as below:

network:
  host: 0.0.0.0
http:
  port: 9200

After this restart the elastic service. If something goes wrong, refer to elastic log files and check if the instance is bound to the above IP and port 9200. You can also check the listening IP/port (netstat -l -n) . There has to be an entry like:

tcp 0 0 0.0.0.0:9200 0.0.0.0:* LISTEN 

Hope this helps and happy searching..

1 Like

What does that mean, what did you have?
It might help us help someone else from having this issue in the future.

The default YML file follows the format of ProertyGroup.PropertyName : PropertyValue
for eg:

cluster.name: od-fts1
network.bind_host: 192.168.0.1

Following the same principles, I entered

network.host: 0.0.0.0

But with the above network.host config, elastic was not able to start the server. Default port 9200 was not opened.

So I restructured my elasticsearch.yml and it started working (for localhost & oustide). Here is the final version of what I have now:

cluster:
name: rules

node:
name: "node_32"

network:
host: 0.0.0.0

The node.name style definitely works.

Hi, I face the same problem.
After install deb I start service with default settings, at local machine everything was ok, and i have access from localhost, but from outside i have "no living connection" error. I changed network.host to
104.199.112.18. after that i try to start and service crashed. Any changing network.host cause crashes: _local_ , 0.0.0.0. But when I just change port or comment setting all goings well. do you have any ideas?

It sounds like you might be on Elasticsearch 5.x and be affected by the new bootstrap checks. If not, please open a new issue with a more detailed description of your problem.