# Error: expected 'location' header to be set

**URL:** https://discuss.elastic.co/t/error-expected-location-header-to-be-set/248025
**Category:** Kibana
**Created:** [September 9, 2020, 2:03pm UTC](https://discuss.elastic.co/t/error-expected-location-header-to-be-set/248025 "2020-09-09T14:03:01Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![TamiTakamiya](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@TamiTakamiya](https://discuss.elastic.co/u/TamiTakamiya)
#### Post date: [September 9, 2020, 2:03pm UTC](https://discuss.elastic.co/t/error-expected-location-header-to-be-set/248025/1 "2020-09-09T14:03:01Z")

</div>

Hello, I have an issue in connecting Kibana (7.8.0 OSS) running on my local machine to our Elasticsearch (7.8.0) instance on our Kubernates cluster.

The initial connection works and Kibana creates the index `.kibana_1` on Elasticsearch. However, when I try to run a search, it fails with a 500 error with following message:

```auto
      log [13:52:56.588] [error][http] Error: expected 'location' header to be set
        at HapiResponseAdapter.toRedirect (/Users/ttakamiy@us.ibm.com/kibana/kibana-7.8.0-darwin-x86_64/src/core/server/http/router/response_adapter.js:112:13)
        at HapiResponseAdapter.toHapiResponse (/Users/ttakamiy@us.ibm.com/kibana/kibana-7.8.0-darwin-x86_64/src/core/server/http/router/response_adapter.js:94:19)
        at HapiResponseAdapter.handle (/Users/ttakamiy@us.ibm.com/kibana/kibana-7.8.0-darwin-x86_64/src/core/server/http/router/response_adapter.js:81:17)
        at Router.handle (/Users/ttakamiy@us.ibm.com/kibana/kibana-7.8.0-darwin-x86_64/src/core/server/http/router/router.js:160:34)
        at process._tickCallback (internal/process/next_tick.js:68:7)
     error [13:52:56.429] Error: Internal Server Error
        at HapiResponseAdapter.toInternalError (/Users/ttakamiy@us.ibm.com/kibana/kibana-7.8.0-darwin-x86_64/src/core/server/http/router/response_adapter.js:69:19)
        at Router.handle (/Users/ttakamiy@us.ibm.com/kibana/kibana-7.8.0-darwin-x86_64/src/core/server/http/router/router.js:163:34)
        at process._tickCallback (internal/process/next_tick.js:68:7)

```

Can anybody see anything that potentially causes this kind of errors? Thank you!

Tami

---

<div class="post-metadata">

### Author: ![corey.robertson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corey.robertson/32/54611_2.png) [@corey.robertson](https://discuss.elastic.co/u/corey.robertson)
#### Post date: [September 9, 2020, 4:54pm UTC](https://discuss.elastic.co/t/error-expected-location-header-to-be-set/248025/2 "2020-09-09T16:54:45Z")

</div>

Hi @TamiTakamiya

How are you running this search that is causing this error to happen?

---

<div class="post-metadata">

### Author: ![TamiTakamiya](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@TamiTakamiya](https://discuss.elastic.co/u/TamiTakamiya)
#### Post date: [September 9, 2020, 6:33pm UTC](https://discuss.elastic.co/t/error-expected-location-header-to-be-set/248025/3 "2020-09-09T18:33:06Z")

</div>

It can be caused by clicking one of my search on Kibana screen. For example, running the `GET /` can cause the error.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/7/778fb6253810972d99c4d0555af8e7716eddfbd6.png)

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [September 10, 2020, 4:56pm UTC](https://discuss.elastic.co/t/error-expected-location-header-to-be-set/248025/4 "2020-09-10T16:56:52Z")

</div>

Can you click the "Wrench" icon, select "Copy as cURL", and then try pasting it into your terminal and running it from there? The cURL request should be something like this:

```auto
curl -XGET "http://localhost:9200/"

```

I'm trying to narrow down whether this is an issue within Console or a problem with the way Kibana is interacting with the Kubernetes cluster. Thanks.

---

<div class="post-metadata">

### Author: ![TamiTakamiya](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@TamiTakamiya](https://discuss.elastic.co/u/TamiTakamiya)
#### Post date: [September 10, 2020, 8:35pm UTC](https://discuss.elastic.co/t/error-expected-location-header-to-be-set/248025/5 "2020-09-10T20:35:28Z")

</div>

"Wrench" icon gave me the correct URL without user/password. By providing the user/password with curl's -p option, I could run the generated curl command successfully.

---

<div class="post-metadata">

### Author: ![TamiTakamiya](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@TamiTakamiya](https://discuss.elastic.co/u/TamiTakamiya)
#### Post date: [September 14, 2020, 4:19am UTC](https://discuss.elastic.co/t/error-expected-location-header-to-be-set/248025/6 "2020-09-14T04:19:53Z")

</div>

I still do not fully understand how this error occurs, but could find a workaround.

When the error occurs, my local Kibana instance seemed to sends to send a request to Elasticsearch with following headers:

```auto
x-forwarded-for: 127.0.0.1
x-forwarded-port: 52048
x-forwarded-proto: http
x-forwarded-host: localhost:5601

```

Among them `x-forwarded-proto: http` is the one causing this. If I send a valid Elasticsearch query with it using curl, I got:

```auto
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

```

So I guess our nginx (Kubernetes Ingress) is configured in that way.

My workaround is to force Kibana not to generate those headers, i.e. edit `kibana-7.8.0-darwin-x86_64/src/plugins/console/server/routes/api/console/proxy/create_handler.js` and comment out following lines:

```auto
  if ((_req === null || _req === void 0 ? void 0 : (_req$info = _req.info) === null || _req$info === void 0 ? void 0 : _req$info.remotePort) && (_req === null || _req === void 0 ? void 0 : (_req$info2 = _req.info) === null || _req$info2 === void 0 ? void 0 : _req$info2.remoteAddress)) {
    // see https://git.io/vytQ7
    extendCommaList(headers, 'x-forwarded-for', _req.info.remoteAddress);
    extendCommaList(headers, 'x-forwarded-port', _req.info.remotePort);
    extendCommaList(headers, 'x-forwarded-proto', _req.server.info.protocol);
    extendCommaList(headers, 'x-forwarded-host', _req.info.host);
  }

```

in the function `getProxyHeaders`. Although there would be a cleaner fix, Kibana OSS 7.8.0 works for me with that modification.

Tami

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [September 15, 2020, 5:57pm UTC](https://discuss.elastic.co/t/error-expected-location-header-to-be-set/248025/7 "2020-09-15T17:57:44Z")

</div>

Thanks for the information, Tami! I don't know a lot about nginx, but I wonder if this is something you can solve by changing its configuration.

---

<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: [October 13, 2020, 5:57pm UTC](https://discuss.elastic.co/t/error-expected-location-header-to-be-set/248025/8 "2020-10-13T17:57:53Z")

</div>

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