# Elasticsearch : Curl -X GET “localhost:9200” gives “Network Error (dns\_unresolved\_hostname)”

**URL:** <https://discuss.elastic.co/t/elasticsearch-curl-x-get-localhost-9200-gives-network-error-dns-unresolved-hostname/184942>\
**Category:** Elasticsearch\
**Created:** [June 10, 2019, 8:04am UTC](https://discuss.elastic.co/t/elasticsearch-curl-x-get-localhost-9200-gives-network-error-dns-unresolved-hostname/184942 "2019-06-10T08:04:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sundaramoorthy\_Anand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sundaramoorthy_anand/32/47787_2.png) [@Sundaramoorthy\_Anand](https://discuss.elastic.co/u/Sundaramoorthy_Anand)\
**Post date:** [June 10, 2019, 8:04am UTC](https://discuss.elastic.co/t/elasticsearch-curl-x-get-localhost-9200-gives-network-error-dns-unresolved-hostname/184942/1 "2019-06-10T08:04:31Z")

</div>

I have installed as `.tar.gz` using `wget` and `chown`-ed the elasticsearch folder as a `xyz` user and `xyzgrp` group .

I did run the es using `./bin/elasticsearch` and it ran fine with no errors.

then I curl-ed, curl -X GET "localhost:9200" which gives the following error. But if I run as root curl is spitting out the expected output.

**as xyz user:**

Network Error  

> | Network Error (dns\_unresolved\_hostname)  
>   
> |
> | Your requested host "localhost" could not be resolved by DNS. |
> | |
> |   
> For assistance, contact your network support team. |

**as root:**

{  
"name" : "wE3SaRO",  
"cluster\_name" : "elasticsearch",  
"cluster\_uuid" : "YobA\_1NiT\_aHGlgQhAWdZA",  
"version" : {  
"number" : "6.4.2",  
"build\_flavor" : "default",  
"build\_type" : "tar",  
"build\_hash" : "04711c2",  
"build\_date" : "2018-09-26T13:34:09.098244Z",  
"build\_snapshot" : false,  
"lucene\_version" : "7.4.0",  
"minimum\_wire\_compatibility\_version" : "5.6.0",  
"minimum\_index\_compatibility\_version" : "5.0.0"  
},  
"tagline" : "You Know, for Search"  
}  
one more thing, i'm running the elasticsearch as xyz user not as root

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [June 10, 2019, 1:21pm UTC](https://discuss.elastic.co/t/elasticsearch-curl-x-get-localhost-9200-gives-network-error-dns-unresolved-hostname/184942/2 "2019-06-10T13:21:29Z")

</div>

It seems your system cannot resolve `localhost` which sounds extremely weird and more like a misconfiguration on your system. Can you run `curl 127.0.0.1:9200` - does it work?

---

<div class="post-metadata">

**Author:** ![Sundaramoorthy\_Anand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sundaramoorthy_anand/32/47787_2.png) [@Sundaramoorthy\_Anand](https://discuss.elastic.co/u/Sundaramoorthy_Anand)\
**Post date:** [June 11, 2019, 6:21am UTC](https://discuss.elastic.co/t/elasticsearch-curl-x-get-localhost-9200-gives-network-error-dns-unresolved-hostname/184942/3 "2019-06-11T06:21:22Z")

</div>

`curl 127.0.0.1:9200`

```
> <HTML>
> <HEAD><TITLE>Redirection</TITLE></HEAD>
> <BODY><H1>Redirect</H1></BODY>

```

This is what curl is spitting out ☹

What could be the misconfiged part? any guess?

---

<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:** [June 11, 2019, 6:52am UTC](https://discuss.elastic.co/t/elasticsearch-curl-x-get-localhost-9200-gives-network-error-dns-unresolved-hostname/184942/4 "2019-06-11T06:52:41Z")

</div>

Sounds like you have a proxy may be?

---

<div class="post-metadata">

**Author:** ![martinr\_ubi](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@martinr\_ubi](https://discuss.elastic.co/u/martinr_ubi)\
**Post date:** [June 11, 2019, 6:53am UTC](https://discuss.elastic.co/t/elasticsearch-curl-x-get-localhost-9200-gives-network-error-dns-unresolved-hostname/184942/5 "2019-06-11T06:53:38Z")

</div>

Was going to say the same thing, compare:

```auto
env | grep -i proxy

```

as root and as xyz

---

<div class="post-metadata">

**Author:** ![Sundaramoorthy\_Anand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sundaramoorthy_anand/32/47787_2.png) [@Sundaramoorthy\_Anand](https://discuss.elastic.co/u/Sundaramoorthy_Anand)\
**Post date:** [June 11, 2019, 7:02am UTC](https://discuss.elastic.co/t/elasticsearch-curl-x-get-localhost-9200-gives-network-error-dns-unresolved-hostname/184942/6 "2019-06-11T07:02:16Z")

</div>

`env | grep -i proxy`

**as xyz user**  
http\_proxy=http://web-proxy.corp.mycomp.net:8080  
https\_proxy=http://web-proxy.corp.mycomp.net:8080

**as root** , it spits the same thing.. but if I'm not giving any proxy, I cannot download any packages because I'm inside my company network

---

<div class="post-metadata">

**Author:** ![martinr\_ubi](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@martinr\_ubi](https://discuss.elastic.co/u/martinr_ubi)\
**Post date:** [June 11, 2019, 7:24am UTC](https://discuss.elastic.co/t/elasticsearch-curl-x-get-localhost-9200-gives-network-error-dns-unresolved-hostname/184942/7 "2019-06-11T07:24:59Z")

</div>

That's your issue, it is completely unrelated to Elasticsearch.  
You cannot reliably call the local server (localhost, 127.0.0.1) through a remote proxy used to go out on the internet.

Try:

```auto
curl -X GET "localhost:9200" --noproxy

```

Read:  
[https://ec.haxx.se/usingcurl-proxies.html](https://ec.haxx.se/usingcurl-proxies.html)  
(Specifically the section called " Proxy environment variables")

Talk to your system administrator if you need assistance locally calling services on a server WITHOUT using a proxy or between servers in the same vlan.

Your user session on your servers is configured to send all HTTP/HTTPS traffic toward a remote proxy server, which breaks your call toward Elasticsearch which is installed locally on the server and which you are trying to call directly and locally.

---

<div class="post-metadata">

**Author:** ![Sundaramoorthy\_Anand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sundaramoorthy_anand/32/47787_2.png) [@Sundaramoorthy\_Anand](https://discuss.elastic.co/u/Sundaramoorthy_Anand)\
**Post date:** [June 11, 2019, 10:14am UTC](https://discuss.elastic.co/t/elasticsearch-curl-x-get-localhost-9200-gives-network-error-dns-unresolved-hostname/184942/8 "2019-06-11T10:14:40Z")

</div>

yeah this one works !

`curl -X GET "localhost:9200" --noproxy "*"`

```
{
  "name" : "wE3SaRO",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "YobA_1NiT_aHGlgQhAWdZA",
  "version" : {
    "number" : "6.4.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "04711c2",
    "build_date" : "2018-09-26T13:34:09.098244Z",
    "build_snapshot" : false,
    "lucene_version" : "7.4.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

```

This works for me ,but not sure whether ES will accompany LS and KB well . Will post after checking . Thanks a lot!

Thanks for others too 🙏

---

<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 9, 2019, 10:26am UTC](https://discuss.elastic.co/t/elasticsearch-curl-x-get-localhost-9200-gives-network-error-dns-unresolved-hostname/184942/9 "2019-07-09T10:26:06Z")

</div>

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