Curl: (7) failed to connect

Hello,

I have an application that requires ElasticSearch as one of its components to work with the application. After successfully installing ElasticSearch, my application wants me to run the CURL -XGET command from another server. When I run the command from another server I get curl: (7) Failed connect to "ipaddressfromESserver":9200 Connection refused. I also get the same error message on the server that has ES installed. ElasticSearch 2.4 is hosted on Red Hat 7.2.

What are the potential reasons why I am experiencing this issue?

1 Like

By default Elasticsearch only listens to localhost. You may need to set network.host to something else.

Check out https://www.elastic.co/guide/en/elasticsearch/reference/6.2/network.host.html

Hello when I type "ipaddressfromESServer" in this forum, I am referring to the ip address of the server. What is consider the localhost? Is the 127.0.0.1 address or you referring to the ip address of the where ES is installed?

Hello,

How can I get it to listen on the ip address that I installed ES? I review the link provided but I dont understand what to do next?

If you're not familiar with localhost, then check out https://whatismyipaddress.com/localhost

You need to set network.host to something, 0.0.0.0 will bind to all IPs and interfaces on the host, if that is what you want.

Thanks for providing the info. I check out localhost earlier. In regards to my issues, I change the network.host to 0.0.0.0. When I enter the following I still receive an error message: [root@OUSNWA2H elasticsearch]# curl -XGET OUSNWA2H:9200
curl: (7) Failed connect to OUSNWA2H:9200; Connection refused
[root@OUSNWA2H elasticsearch]#

How can I get the curl command to use the servername provided. How can I also used the same command with the servername in the syntax from another server?

What do the logs of Elasticsearch show?

Which log do you want me to provide?

@warkolm asked for elasticsearch logs.

Hello,

What location can I find the elasticsearch logs? I installed the application using rpm.

Thanks

I think I found it. Here is the log:

[root@OUSNWA2H elasticsearch]# vi elasticsearch.log.2018-02-15
[2018-02-15 11:53:37,096][INFO ][node ] [Watcher] stopping ...
[2018-02-15 11:53:37,115][INFO ][node ] [Watcher] stopped
[2018-02-15 11:53:37,115][INFO ][node ] [Watcher] closing ...
[2018-02-15 11:53:37,122][INFO ][node ] [Watcher] closed
[2018-02-15 11:53:38,033][INFO ][node ] [Jawynn Dueck the Iron Christian of Faith] version[2.4.0], pid[29223], build[ce9f0c7/2016-08-29T09:14:17Z]
[2018-02-15 11:53:38,034][INFO ][node ] [Jawynn Dueck the Iron Christian of Faith] initializing ...
[2018-02-15 11:53:38,673][INFO ][plugins ] [Jawynn Dueck the Iron Christian of Faith] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2018-02-15 11:53:38,701][INFO ][env ] [Jawynn Dueck the Iron Christian of Faith] using [1] data paths, mounts [[/var (/dev/mapper/rootvg-var)]], net usable_space [5.6gb], net total_space [6.4gb], spins? [possibly], types [xfs]
[2018-02-15 11:53:38,701][INFO ][env ] [Jawynn Dueck the Iron Christian of Faith] heap size [990.7mb], compressed ordinary object pointers [true]
[2018-02-15 11:53:40,668][INFO ][node ] [Jawynn Dueck the Iron Christian of Faith] initialized
[2018-02-15 11:53:40,668][INFO ][node ] [Jawynn Dueck the Iron Christian of Faith] starting ...
[2018-02-15 11:53:40,741][INFO ][transport ] [Jawynn Dueck the Iron Christian of Faith] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2018-02-15 11:53:40,748][INFO ][discovery ] [Jawynn Dueck the Iron Christian of Faith] elasticsearch/bMO39iuVQyaFHsxXTnxquA
[2018-02-15 11:53:43,803][INFO ][cluster.service ] [Jawynn Dueck the Iron Christian of Faith] new_master {Jawynn Dueck the Iron Christian of Faith}{bMO39iuVQyaFHsxXTnxquA}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)

How do I get to see my node and not random nodes?

[root@OUSNWA2H elasticsearch]# vi elasticsearch.log.2018-02-15
[2018-02-15 21:05:59,753][INFO ][node ] [Power Broker] stopped
[2018-02-15 21:05:59,753][INFO ][node ] [Power Broker] closing ...
[2018-02-15 21:05:59,758][INFO ][node ] [Power Broker] closed
[2018-02-15 21:06:00,530][INFO ][node ] [Professor X] version[2.4.0], pid[19297], build[ce9f0c7/2016-08-29T09:14:17Z]
[2018-02-15 21:06:00,531][INFO ][node ] [Professor X] initializing ...
[2018-02-15 21:06:01,065][INFO ][plugins ] [Professor X] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2018-02-15 21:06:01,087][INFO ][env ] [Professor X] using [1] data paths, mounts [[/var (/dev/mapper/rootvg-var)]], net usable_space [5.6gb], net total_space [6.4gb], spins? [possibly], types [xfs]
[2018-02-15 21:06:01,087][INFO ][env ] [Professor X] heap size [990.7mb], compressed ordinary object pointers [true]
[2018-02-15 21:06:02,710][INFO ][node ] [Professor X] initialized
[2018-02-15 21:06:02,710][INFO ][node ] [Professor X] starting ...
[2018-02-15 21:06:02,781][INFO ][transport ] [Professor X] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2018-02-15 21:06:02,787][INFO ][discovery ] [Professor X] elasticsearch/ykNJ2ybxQxuppXR8yTvzoA
[2018-02-15 21:06:05,833][INFO ][cluster.service ] [Professor X] new_master {Professor X}{ykNJ2ybxQxuppXR8yTvzoA}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2018-02-15 21:06:05,854][INFO ][http ] [Professor X] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2018-02-15 21:06:05,854][INFO ][node ] [Professor X] started
[2018-02-15 21:06:05,868][INFO ][gateway ] [Professor X] recovered [0] indices into cluster_state

/[root@OUSNWA2H elasticsearch]# vi elasticsearch.log
[2018-02-16 10:19:05,405][WARN ][http.netty ] [Professor X] Caught exception while handling client http traffic, closing connection [id: 0xab749283, /0:0:0:0:0:0:0:1:56482 => /0:0:0:0:0:0:0:1:9200]
java.lang.IllegalArgumentException: empty text
at org.jboss.netty.handler.codec.http.HttpVersion.(HttpVersion.java:89)
at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62)
at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75)
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:191)
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:102)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500)
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:485)
at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
at org.elasticsearch.common.netty.OpenChannelsHandler.handleUpstream(OpenChannelsHandler.java:75)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)/

Is this what you mean? @dadoonet

Please format your code using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

Please edit your posts.

Anyway your server is listening here on 127.0.0.1:9200. So the only way to access it is locally with curl 127.0.0.1:9200/.

If you want to be able to access it from another machine, then you need to configure properly what @warkolm told you

Thanks....I review what @warkolm mentioned. Can you provide an example?

Hello,

I do not understand what you mean by editing my code. I provide the logs not code is there a different method to do so?

Thanks

Format your logs if you prefer.

What did you do to follow what Mark wrote?

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