# Logstash got response code 401 contacting elasticsearch url

**URL:** <https://discuss.elastic.co/t/logstash-got-response-code-401-contacting-elasticsearch-url/317081>\
**Category:** Logstash\
**Tags:** docker\
**Created:** [October 20, 2022, 8:40am UTC](https://discuss.elastic.co/t/logstash-got-response-code-401-contacting-elasticsearch-url/317081 "2022-10-20T08:40:42Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![mammodde](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@mammodde](https://discuss.elastic.co/u/mammodde)\
**Post date:** [October 21, 2022, 8:06am UTC](https://discuss.elastic.co/t/logstash-got-response-code-401-contacting-elasticsearch-url/317081/7 "2022-10-21T08:06:38Z")

</div>

Finally i found what was missing  
inside logstash.yml you have to put `xpack.monitoring.elasticsearch.username` and `xpack.monitoring.elasticsearch.password` .  
I don't know why these fields are not specified in [logstash.yml | Logstash Reference [8.4] | Elastic](https://www.elastic.co/guide/en/logstash/current/logstash-settings-file.html)

---

_[View the full topic](https://discuss.elastic.co/t/logstash-got-response-code-401-contacting-elasticsearch-url/317081)._
