Error: expected 'location' header to be set

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:

      log   [13:52:56.588] [error][http] Error: expected 'location' header to be set
        at HapiResponseAdapter.toRedirect (/Users/
        at HapiResponseAdapter.toHapiResponse (/Users/
        at HapiResponseAdapter.handle (/Users/
        at Router.handle (/Users/
        at process._tickCallback (internal/process/next_tick.js:68:7)
     error  [13:52:56.429]  Error: Internal Server Error
        at HapiResponseAdapter.toInternalError (/Users/
        at Router.handle (/Users/
        at process._tickCallback (internal/process/next_tick.js:68:7)

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


Hi @TamiTakamiya

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

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

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:

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.

"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.

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:

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:

<head><title>301 Moved Permanently</title></head>
<center><h1>301 Moved Permanently</h1></center>

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:

  if ((_req === null || _req === void 0 ? void 0 : (_req$info = === null || _req$info === void 0 ? void 0 : _req$info.remotePort) && (_req === null || _req === void 0 ? void 0 : (_req$info2 = === null || _req$info2 === void 0 ? void 0 : _req$info2.remoteAddress)) {
    // see
    extendCommaList(headers, 'x-forwarded-for',;
    extendCommaList(headers, 'x-forwarded-port',;
    extendCommaList(headers, 'x-forwarded-proto',;
    extendCommaList(headers, 'x-forwarded-host',;

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


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.

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