# Curl: (7) failed to connect

**URL:** <https://discuss.elastic.co/t/curl-7-failed-to-connect/120073>\
**Category:** Elasticsearch\
**Created:** [February 15, 2018, 9:30pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073 "2018-02-15T21:30:42Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![brownri](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@brownri](https://discuss.elastic.co/u/brownri)\
**Post date:** [February 15, 2018, 9:30pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/1 "2018-02-15T21:30:42Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 15, 2018, 9:32pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/2 "2018-02-15T21:32:19Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/network.host.html)

---

<div class="post-metadata">

**Author:** ![brownri](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@brownri](https://discuss.elastic.co/u/brownri)\
**Post date:** [February 15, 2018, 9:36pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/3 "2018-02-15T21:36:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![brownri](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@brownri](https://discuss.elastic.co/u/brownri)\
**Post date:** [February 15, 2018, 9:56pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/4 "2018-02-15T21:56:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 15, 2018, 11:38pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/5 "2018-02-15T23:38:54Z")

</div>

If you're not familiar with localhost, then check out [https://whatismyipaddress.com/localhost](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.

---

<div class="post-metadata">

**Author:** ![brownri](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@brownri](https://discuss.elastic.co/u/brownri)\
**Post date:** [February 16, 2018, 2:16am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/6 "2018-02-16T02:16:15Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [February 16, 2018, 2:52am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/7 "2018-02-16T02:52:18Z")

</div>

What do the logs of Elasticsearch show?

---

<div class="post-metadata">

**Author:** ![brownri](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@brownri](https://discuss.elastic.co/u/brownri)\
**Post date:** [February 16, 2018, 3:59pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/8 "2018-02-16T15:59:43Z")

</div>

Which log do you want me to provide?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 16, 2018, 4:54pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/9 "2018-02-16T16:54:43Z")

</div>

@warkolm asked for elasticsearch logs.

---

<div class="post-metadata">

**Author:** ![brownri](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@brownri](https://discuss.elastic.co/u/brownri)\
**Post date:** [February 16, 2018, 5:21pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/10 "2018-02-16T17:21:40Z")

</div>

Hello,

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

Thanks

---

<div class="post-metadata">

**Author:** ![brownri](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@brownri](https://discuss.elastic.co/u/brownri)\
**Post date:** [February 16, 2018, 5:27pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/11 "2018-02-16T17:27:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![brownri](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@brownri](https://discuss.elastic.co/u/brownri)\
**Post date:** [February 16, 2018, 5:28pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/12 "2018-02-16T17:28:11Z")

</div>

[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

---

<div class="post-metadata">

**Author:** ![brownri](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@brownri](https://discuss.elastic.co/u/brownri)\
**Post date:** [February 16, 2018, 5:29pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/13 "2018-02-16T17:29:09Z")

</div>

/[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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 16, 2018, 6:10pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/14 "2018-02-16T18:10:08Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) 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

> [@Curl: (7) failed to connect](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/5):
>
> If you're not familiar with localhost, then check out [https://whatismyipaddress.com/localhost](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.

---

<div class="post-metadata">

**Author:** ![brownri](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@brownri](https://discuss.elastic.co/u/brownri)\
**Post date:** [February 16, 2018, 6:52pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/15 "2018-02-16T18:52:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![brownri](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@brownri](https://discuss.elastic.co/u/brownri)\
**Post date:** [February 16, 2018, 6:55pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/16 "2018-02-16T18:55:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 16, 2018, 10:48pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/17 "2018-02-16T22:48:15Z")

</div>

Format your logs if you prefer.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 16, 2018, 10:48pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/18 "2018-02-16T22:48:52Z")

</div>

What did you do to follow what Mark wrote?

---

<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:** [March 16, 2018, 10:48pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect/120073/19 "2018-03-16T22:48:56Z")

</div>

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