# Can't curl expected results using public, private or localhost ip

**URL:** <https://discuss.elastic.co/t/cant-curl-expected-results-using-public-private-or-localhost-ip/9167>\
**Category:** Elasticsearch\
**Created:** [September 27, 2012, 8:15am UTC](https://discuss.elastic.co/t/cant-curl-expected-results-using-public-private-or-localhost-ip/9167 "2012-09-27T08:15:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jasey\_Wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasey_wang/32/2707_2.png) [@Jasey\_Wang](https://discuss.elastic.co/u/Jasey_Wang)\
**Post date:** [September 27, 2012, 8:15am UTC](https://discuss.elastic.co/t/cant-curl-expected-results-using-public-private-or-localhost-ip/9167/1 "2012-09-27T08:15:52Z")

</div>

hi all

I have _2_ nics on my ubuntu server, eth0 for private ip and eth1 for  
public ip, and a loopback nic which is localhost, according to the guide  
below:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

there are mainly three settings for networking:  
network.bind\_host for bind  
network.publish\_host for communicate  
network.host for above all  
default binds itself to the 0.0.0.0 address, and I start the es without  
changing the net config using wrappers:

_root@es:~# /etc/init.d/elasticsearch start_  
Starting Elasticsearch...  
Waiting for Elasticsearch......  
running: PID:2967

_root@es:~# netstat -tunlp_  
Active Internet connections (only servers)  
Proto Recv-Q Send-Q Local Address Foreign Address  
State PID/Program name  
tcp 0 0 127.0.0.1:32000 0.0.0.0:\*  
LISTEN 2969/java  
tcp 0 0 0.0.0.0:9200 0.0.0.0:\*  
LISTEN 2969/java  
tcp 0 0 0.0.0.0:9300 0.0.0.0:\*  
LISTEN 2969/java  
tcp 0 0 0.0.0.0:22 0.0.0.0:\*  
LISTEN 419/sshd  
udp 0 0 0.0.0.0:54328  
0.0.0.0:\* 2969/java

and as the netstat shows, it really listens on 0.0.0.0:9200  
then I uss curl to have a test, only works for public ip, not localhost nor  
my private ip:

_# curl -XGET '[http://122.x.x.x:9200/\_cluster/health?pretty=true](http://122.x.x.x:9200/_cluster/health?pretty=true)'_  
{  
"cluster\_name" : "graylog2orlogstash",  
"status" : "green",  
"timed\_out" : false,  
"number\_of\_nodes" : 1,  
"number\_of\_data\_nodes" : 1,  
"active\_primary\_shards" : 0,  
"active\_shards" : 0,  
"relocating\_shards" : 0,  
"initializing\_shards" : 0,  
"unassigned\_shards" : 0  
}

curl localhost, and return the below error:  
_# curl -XGET '[http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)'_

 \<meta 

http-equiv="Content-Type" CONTENT="text/html; charset=utf-8"\> ERROR:  
The requested URL could not be retrieved

 
# ERROR
 
## The requested URL could not be retrieved
 
 
* * *

 

The following error was  
encountered while trying to retrieve the URL: [http://localhost:9200/\_cluster/health?](http://localhost:9200/_cluster/health?)

> **Connection to 127.0.0.1 failed.**

The system returned: _(111) Connection refused_

The remote host or network may be down. Please try the request again.

Your cache administrator is [webmaster](mailto:webmaster%W).

  
 

* * *
 
 

Generated Thu, 27 Sep 2012 08:03:40 GMT by xxx (squid/2.7.STABLE7)

 root@es:~# 

curl my private ip, it hungs here, and I have to Crtl+c to stop it:  
_# curl -XGET '[http://192.168.1.234:9200/\_cluster/health?pretty=true](http://192.168.1.234:9200/_cluster/health?pretty=true)'_

then, I make a change, I set the network.host to my private ip  
192.168.1.234, and restart again. the netstat shows as expect:

Proto Recv-Q Send-Q Local Address Foreign Address  
State PID/Program name  
tcp 0 0 127.0.0.1:32000 0.0.0.0:\*  
LISTEN 3253/java  
tcp 0 0 192.168.1.234:9200 0.0.0.0:\*  
LISTEN 3253/java  
tcp 0 0 192.168.1.234:9300 0.0.0.0:\*  
LISTEN 3253/java  
udp 0 0 0.0.0.0:54328  
0.0.0.0:\* 3253/java

then I use curl to test, this time, the localhost and the private still  
have the problems as shows above, and curl my public ip, result like my cur  
localhost:  
_# curl -XGET '[http://122.x.x.x:9200/\_cluster/health?pretty=true](http://122.x.x.x:9200/_cluster/health?pretty=true)'_

 \<meta 

http-equiv="Content-Type" CONTENT="text/html; charset=utf-8"\> ERROR:  
The requested URL could not be retrieved

 
# ERROR
 
## The requested URL could not be retrieved
 
 
* * *

 

The following error was  
encountered while trying to retrieve the URL: [http://122.11.52.234:9200/\_cluster/health?](http://122.11.52.234:9200/_cluster/health?)

> **Connection to 122.11.52.234 failed.**

The system returned: _(111) Connection refused_

The remote host or network may be down. Please try the request again.

Your cache administrator is [webmaster](mailto:webmaster%W).

  
 

* * *
 
 

Generated Thu, 27 Sep 2012 08:10:14 GMT by xxx (squid/2.7.STABLE7)

 root@es:/opt/elasticsearch/config# 

I think, it may be my config error, but I don't know where it is, plz have  
a look  
thanks.

--

---

<div class="post-metadata">

**Author:** ![Srinivas\_Mangipudi](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Srinivas\_Mangipudi](https://discuss.elastic.co/u/Srinivas_Mangipudi)\
**Post date:** [January 3, 2017, 7:15am UTC](https://discuss.elastic.co/t/cant-curl-expected-results-using-public-private-or-localhost-ip/9167/2 "2017-01-03T07:15:05Z")

</div>

try using https with port 443

so your hosts should be specified like: [https://yourdomain.com:443](https://yourdomain.com:443)

---

<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:** [July 5, 2017, 10:04pm UTC](https://discuss.elastic.co/t/cant-curl-expected-results-using-public-private-or-localhost-ip/9167/3 "2017-07-05T22:04:34Z")

</div>


