# Can't get status 200

**URL:** <https://discuss.elastic.co/t/cant-get-status-200/76727>\
**Category:** Elasticsearch\
**Created:** [February 28, 2017, 7:03am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727 "2017-02-28T07:03:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumo7](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumo7](https://discuss.elastic.co/u/sumo7)\
**Post date:** [February 28, 2017, 7:03am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/1 "2017-02-28T07:03:44Z")

</div>

When I use the search function in my development environment, Elasticsearch returns status 200 like the following.

```
TRACE: 2017-02-28T06:46:01Z
  -> POST http://localhost:9200/users/_suggest
  {
    "docsuggest": {
      "text": "a",
      "completion": {
        "field": "name_suggest",
        "fuzzy": true
      }
    }
  }
  <- 200
  {
    "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
    },
    "docsuggest": [
      {
        "text": "a",
        "offset": 0,
        "length": 1,
        "options": []
      }
    ]
  }

```

But in production, it returns this.

```
TRACE: 2017-02-28T06:43:44Z
  -> POST http://172.31.18.8:9200/users/_suggest
  {
    "docsuggest": {
      "text": "l",
      "completion": {
        "field": "name_suggest",
        "fuzzy": true
      }
    }
  }
  <- 0

```

How can I get the status 200?

My production setups are as follows.

I have only one master-eligible data node in my cluster.  
I set number\_of\_shards to 1, and number\_of\_replicas to 0.  
Configuration for the elasticsearch.yaml.

```
http.cors.enabled: true
http.cors.allow-origin: /https?:\/\/localhost(:[0-9]+)?/
cluster.name: MyAppName
node.name: ${HOSTNAME}
bootstrap.memory_lock: true
network.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1
```

---

<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 28, 2017, 7:43am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/2 "2017-02-28T07:43:28Z")

</div>

What can you see in elasticsearch logs?

---

<div class="post-metadata">

**Author:** ![sumo7](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumo7](https://discuss.elastic.co/u/sumo7)\
**Post date:** [February 28, 2017, 7:48am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/3 "2017-02-28T07:48:49Z")

</div>

You mean `trace` log?  
If so, it doesn't return any errors.  
It just times out.

---

<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 28, 2017, 8:02am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/4 "2017-02-28T08:02:15Z")

</div>

Can you share them?

---

<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 28, 2017, 8:37am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/7 "2017-02-28T08:37:39Z")

</div>

Don't share screenshots please.

I meant elasticsearch server logs

---

<div class="post-metadata">

**Author:** ![sumo7](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumo7](https://discuss.elastic.co/u/sumo7)\
**Post date:** [February 28, 2017, 8:43am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/8 "2017-02-28T08:43:51Z")

</div>

It doesn't return any server logs.

---

<div class="post-metadata">

**Author:** ![sumo7](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumo7](https://discuss.elastic.co/u/sumo7)\
**Post date:** [February 28, 2017, 8:45am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/9 "2017-02-28T08:45:55Z")

</div>

Only this output from server when I start my web app, not when I execute search.

> 172.31.18.8 - - [28/Feb/2017:08:42:20 +0000] "GET / HTTP/1.1" 304 - "-" "Mozilla/5.0 (X11; Linux x86\_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"

---

<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 28, 2017, 8:50am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/10 "2017-02-28T08:50:42Z")

</div>

Are you sure elasticsearch is running. Are you sure it's started?

Please check your elasticsearch logs and if no logs, search your system logs.

---

<div class="post-metadata">

**Author:** ![sumo7](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumo7](https://discuss.elastic.co/u/sumo7)\
**Post date:** [February 28, 2017, 8:52am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/11 "2017-02-28T08:52:30Z")

</div>

I'm pretty sure it's started.  
How do I search my system logs?

---

<div class="post-metadata">

**Author:** ![sumo7](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumo7](https://discuss.elastic.co/u/sumo7)\
**Post date:** [February 28, 2017, 8:54am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/12 "2017-02-28T08:54:48Z")

</div>

One more thing to add is that I can store data into elasticsearch but can't get it.

---

<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 28, 2017, 9:01am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/13 "2017-02-28T09:01:19Z")

</div>

So you have logs somewhere. Can you share them all please?

---

<div class="post-metadata">

**Author:** ![sumo7](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumo7](https://discuss.elastic.co/u/sumo7)\
**Post date:** [February 28, 2017, 9:05am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/14 "2017-02-28T09:05:23Z")

</div>

I don't have system logs.  
`trace` log is the only log I have.

---

<div class="post-metadata">

**Author:** ![sumo7](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumo7](https://discuss.elastic.co/u/sumo7)\
**Post date:** [February 28, 2017, 9:16am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/15 "2017-02-28T09:16:57Z")

</div>

I mean I have nginx installed on the web server but nginx doesn't have any values from elasticsearch, so I don't have system logs.

---

<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 28, 2017, 9:24am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/16 "2017-02-28T09:24:56Z")

</div>

How did you start elasticsearch?

---

<div class="post-metadata">

**Author:** ![sumo7](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumo7](https://discuss.elastic.co/u/sumo7)\
**Post date:** [February 28, 2017, 9:26am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/17 "2017-02-28T09:26:50Z")

</div>

I installed elasticsearch from tar, so `bin/elasticsearch`.

---

<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 28, 2017, 9:37am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/18 "2017-02-28T09:37:57Z")

</div>

`bin/elasticsearch` creates logs in `logs` dir and on the console where you started it.

---

<div class="post-metadata">

**Author:** ![sumo7](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumo7](https://discuss.elastic.co/u/sumo7)\
**Post date:** [February 28, 2017, 9:42am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/19 "2017-02-28T09:42:24Z")

</div>

The output from starting elasticsearch.

```
[2017-02-28T09:39:32,549][INFO][o.e.n.Node] [ip-172-31-18-8] initializing ...
[2017-02-28T09:39:32,632][INFO][o.e.e.NodeEnvironment] [ip-172-31-18-8] using [1] data paths, mounts [[/ (/dev/xvda1)]], net usable_space [4.4gb], net total_space [7.7gb], spins? [no], types [ext4]
[2017-02-28T09:39:32,633][INFO][o.e.e.NodeEnvironment] [ip-172-31-18-8] heap size [3.9gb], compressed ordinary object pointers [true]
[2017-02-28T09:39:32,642][INFO][o.e.n.Node] [ip-172-31-18-8] version[5.0.2], pid[15363], build[f6b4951/2016-11-24T10:07:18.101Z], OS[Linux/4.4.0-59-generic/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_121/25.121-b13]
[2017-02-28T09:39:33,820][INFO][o.e.p.PluginsService] [ip-172-31-18-8] loaded module [aggs-matrix-stats]
[2017-02-28T09:39:33,820][INFO][o.e.p.PluginsService] [ip-172-31-18-8] loaded module [ingest-common]
[2017-02-28T09:39:33,820][INFO][o.e.p.PluginsService] [ip-172-31-18-8] loaded module [lang-expression]
[2017-02-28T09:39:33,820][INFO][o.e.p.PluginsService] [ip-172-31-18-8] loaded module [lang-groovy]
[2017-02-28T09:39:33,821][INFO][o.e.p.PluginsService] [ip-172-31-18-8] loaded module [lang-mustache]
[2017-02-28T09:39:33,821][INFO][o.e.p.PluginsService] [ip-172-31-18-8] loaded module [lang-painless]
[2017-02-28T09:39:33,821][INFO][o.e.p.PluginsService] [ip-172-31-18-8] loaded module [percolator]
[2017-02-28T09:39:33,821][INFO][o.e.p.PluginsService] [ip-172-31-18-8] loaded module [reindex]
[2017-02-28T09:39:33,822][INFO][o.e.p.PluginsService] [ip-172-31-18-8] loaded module [transport-netty3]
[2017-02-28T09:39:33,822][INFO][o.e.p.PluginsService] [ip-172-31-18-8] loaded module [transport-netty4]
[2017-02-28T09:39:33,823][INFO][o.e.p.PluginsService] [ip-172-31-18-8] no plugins loaded
[2017-02-28T09:39:36,688][INFO][o.e.n.Node] [ip-172-31-18-8] initialized
[2017-02-28T09:39:36,688][INFO][o.e.n.Node] [ip-172-31-18-8] starting ...
[2017-02-28T09:39:36,899][INFO][o.e.t.TransportService] [ip-172-31-18-8] publish_address {172.31.18.8:9300}, bound_addresses {[::]:9300}
[2017-02-28T09:39:36,904][INFO][o.e.b.BootstrapCheck] [ip-172-31-18-8] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2017-02-28T09:39:40,011][INFO][o.e.c.s.ClusterService] [ip-172-31-18-8] new_master {ip-172-31-18-8}{vgNBp0ZVQ9K6JObbMGwq7Q}{H9F1aCFBTQaKq025b7ZXwQ}{172.31.18.8}{172.31.18.8:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2017-02-28T09:39:40,053][INFO][o.e.h.HttpServer] [ip-172-31-18-8] publish_address {172.31.18.8:9200}, bound_addresses {[::]:9200}
[2017-02-28T09:39:40,054][INFO][o.e.n.Node] [ip-172-31-18-8] started
[2017-02-28T09:39:40,213][INFO][o.e.g.GatewayService] [ip-172-31-18-8] recovered [1] indices into cluster_state
[2017-02-28T09:39:40,408][INFO][o.e.c.r.a.AllocationService] [ip-172-31-18-8] Cluster health status changed from [RED] to [GREEN] (reason: [shards started [[users][0]] ...]).
```

---

<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 28, 2017, 11:05am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/20 "2017-02-28T11:05:39Z")

</div>

Thanks. Can you now share a full script which reproduces your problem?

You can find an example of such a script in

> [@About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21):
>
> The heart of the free and open Elastic Stack Elasticsearch is a distributed, RESTful search and analytics engine capable of addressing a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data for lightning fast search, fine‑tuned relevancy, and powerful analytics that scale with ease. warning PLEASE READ THIS SECTION IF IT'S YOUR FIRST POST Some useful links: [elasticsearch reference guide](http://www.elastic.co/guide/en/elasticsearch/reference/current/index.html)[elasticsearch user guide](http://www.elastic.co/guide/en/elasticsearch/guide/current/index.html)[elasticsearch plugins](https://www.elastic.co/guide/en/elasticsearch/plugins/current/index.html)[elasticsearch cl…](https://www.elastic.co/guide/en/elasticsearch/client/index.html)

---

<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 28, 2017, 11:06am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/21 "2017-02-28T11:06:16Z")

</div>

BTW why are you using 5.0.2? Can't you use 5.2.1?

---

<div class="post-metadata">

**Author:** ![sumo7](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumo7](https://discuss.elastic.co/u/sumo7)\
**Post date:** [March 1, 2017, 12:08am UTC](https://discuss.elastic.co/t/cant-get-status-200/76727/22 "2017-03-01T00:08:02Z")

</div>

I use 5.0.2 because the elasticsearch client for Javascript supports up to 5.0.

```
curl -XGET '172.31.18.8:9200/users?pretty'
{
  "users" : {
    "aliases" : { },
    "mappings" : {
      "user" : {
        "properties" : {
          "name_suggest" : {
            "type" : "completion",
            "analyzer" : "simple",
            "preserve_separators" : true,
            "preserve_position_increments" : true,
            "max_input_length" : 50
          }
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1487275613612",
        "number_of_shards" : "1",
        "number_of_replicas" : "0",
        "uuid" : "5wcHeiy7TbyKhLPfeDn5XA",
        "version" : {
          "created" : "5000299"
        },
        "provided_name" : "users"
      }
    }
  }
}

```

The below is for getting data from elasticsearch using Javascript, which fails in production environment.  
One thing to note is that this code works in development environment and the only difference between production and environment is `host: '172.31.18.8:9200'` and `host: 'localhost:9200'` respectively.

```
import React from 'react'
import ReactDOM from 'react-dom'
import elasticsearch from 'elasticsearch'

let client = new elasticsearch.Client({
        host: '172.31.18.8:9200',
        log: 'trace'
})

const App = React.createClass({
        getInitialState () {
                return {
                        results: [],
                        searchResults: 'block'
                }
        },
        handleChange ( event ) {
                const search_query = event.target.value

                client.suggest({
                        index: "users",
                        //type: "user",
                        body: {
                                docsuggest: {
                                        text: search_query,
                                        completion: {
                                                field: "name_suggest",
                                                fuzzy: true
                                        }
                                }
                        }
                }).then(function ( body ) {
                        this.setState({ results: body.docsuggest })
                }.bind(this), function ( error ) {
                        console.trace( error.message );
                });
        },
        render () {
                return (
                        <div onBlur={()=>this.setState({ searchResults: 'none' })} onFocus={()=>this.setState({ searchResults: 'block' })} className="searchInput">
                                <input type="text" onChange={ this.handleChange } placeholder="Search User..." />
                                { this.state.results.map((result) => {
                                        return (
                                        <ul id="searchValue" key="wow">
                                                {result.options[0] ? <a href={"users/" + result.options[0]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[0]._source.name_suggest.input}>{ result.options[0].text}</li></a> : null}
                                                {result.options[1] ? <a href={"users/" + result.options[1]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[1]._source.name_suggest.input}>{ result.options[1].text}</li></a> : null}
                                                {result.options[2] ? <a href={"users/" + result.options[2]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[2]._source.name_suggest.input}>{ result.options[2].text}</li></a> : null}
                                                {result.options[3] ? <a href={"users/" + result.options[3]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[3]._source.name_suggest.input}>{ result.options[3].text}</li></a> : null}
                                                {result.options[4] ? <a href={"users/" + result.options[4]._source.name_suggest.input}><li style={{display: this.state.searchResults}} key={ result.options[4]._source.name_suggest.input}>{ result.options[4].text}</li></a> : null}
                                        </ul>
                                )
                                })
                         }
                        </div>
                )
        }
})

ReactDOM.render( <App />, document.getElementById( 'searchIt' ) )
ReactDOM.render( <App />, document.getElementById( 'searchItSmall' ) )
```

[Next page](https://discuss.elastic.co/t/cant-get-status-200/76727.md?page=2)
