# Metricbeat stuck on "net/http: request canceled (Client.Timeout exceeded while awaiting headers)"

**URL:** <https://discuss.elastic.co/t/metricbeat-stuck-on-net-http-request-canceled-client-timeout-exceeded-while-awaiting-headers/273177>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [May 17, 2021, 1:23pm UTC](https://discuss.elastic.co/t/metricbeat-stuck-on-net-http-request-canceled-client-timeout-exceeded-while-awaiting-headers/273177 "2021-05-17T13:23:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![just-a-devops-mby](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/just-a-devops-mby/32/88843_2.png) [@just-a-devops-mby](https://discuss.elastic.co/u/just-a-devops-mby)\
**Post date:** [May 17, 2021, 1:23pm UTC](https://discuss.elastic.co/t/metricbeat-stuck-on-net-http-request-canceled-client-timeout-exceeded-while-awaiting-headers/273177/1 "2021-05-17T13:23:28Z")

</div>

Hi!  
I'm having trouble with loading template into Elasticsearch.

My cluster currently contains only one VM. Since i finished it's set up i moved into shipping data from the external VM via Metricbeat... and it didn't went as planned.  
I can't load a template or event ship some data. The weirdest part of it is that  
sometimes it works (5% of attemps), but mainly not.  
From Metricbeat the only error im getting is:

```auto
May 17 14:23:09 HOSTNAME-X metricbeat[24832]: 2021-05-17T14:23:09.740+0200 ERROR [publisher_pipeline_output] pipeline/output.go:154 Failed to connect to backoff(elasticsearch(https://MYELASTIC:9200)): Connection marked as failed because the onConnect callback failed: error loading template: could not load template. Elasticsearch returned: couldn't load template: Put "https://MYELASTIC:9200/_index_template/metricbeat-HOSTNAME-X-7.12.1": net/http: request canceled (Client.Timeout exceeded while awaiting headers) 

```

Even if it works by accident the next thing i get is:

```auto
May 17 13:29:51 HOSTNAME-X metricbeat[29339]: 2021-05-17T13:29:51.334+0200 ERROR [elasticsearch] elasticsearch/client.go:224 failed to perform any bulk index operations: Post "https://MYELASTIC:9200/_bulk": net/http: request canceled (Client.Timeout exceeded while awaiting headers) 

```

The:

```auto
metricbeat setup --index-management

```

end with the same result as loading template via daemon at its start.

Are those connection related issuses? Or i need to look deeper into logs? Does Metricbeat requires two ways connection? Elasticsearch \< -- \> Metricbeat ?

I have checked logs on Elasticsearch service but there was no logs related to issue.

---

<div class="post-metadata">

**Author:** ![just-a-devops-mby](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/just-a-devops-mby/32/88843_2.png) [@just-a-devops-mby](https://discuss.elastic.co/u/just-a-devops-mby)\
**Post date:** [May 17, 2021, 1:29pm UTC](https://discuss.elastic.co/t/metricbeat-stuck-on-net-http-request-canceled-client-timeout-exceeded-while-awaiting-headers/273177/2 "2021-05-17T13:29:53Z")

</div>

I have tested the connection from HOSTNAME-X into Elasticsearch, and its working:

```auto
curl https://MYELASTIC:9200 --cacert /etc/metricbeat/elasticsearch-ca.pem 
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}}],"type":"security_exception","reason":"missing authentication credentials for REST request [/]","header":{"WWW-Authenticate":["Basic realm=\"security\" charset=\"UTF-8\"","Bearer realm=\"security\"","ApiKey"]}},"status":401}

```

So what can be cause of `request canceled (Client.Timeout exceeded while awaiting headers) `?

---

<div class="post-metadata">

**Author:** ![just-a-devops-mby](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/just-a-devops-mby/32/88843_2.png) [@just-a-devops-mby](https://discuss.elastic.co/u/just-a-devops-mby)\
**Post date:** [May 17, 2021, 2:23pm UTC](https://discuss.elastic.co/t/metricbeat-stuck-on-net-http-request-canceled-client-timeout-exceeded-while-awaiting-headers/273177/3 "2021-05-17T14:23:05Z")

</div>

Can the cause be a too slow output connection?

---

<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:** [June 14, 2021, 4:24pm UTC](https://discuss.elastic.co/t/metricbeat-stuck-on-net-http-request-canceled-client-timeout-exceeded-while-awaiting-headers/273177/4 "2021-06-14T16:24:01Z")

</div>

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