# Intermittently failed with 401 Unauthorized

**URL:** <https://discuss.elastic.co/t/intermittently-failed-with-401-unauthorized/288835>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-security\
**Created:** [November 10, 2021, 1:58am UTC](https://discuss.elastic.co/t/intermittently-failed-with-401-unauthorized/288835 "2021-11-10T01:58:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Luong\_Nhat\_Truo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john_luong_nhat_truo/32/77625_2.png) [@John\_Luong\_Nhat\_Truo](https://discuss.elastic.co/u/John_Luong_Nhat_Truo)\
**Post date:** [November 10, 2021, 1:58am UTC](https://discuss.elastic.co/t/intermittently-failed-with-401-unauthorized/288835/1 "2021-11-10T01:58:12Z")

</div>

Hi,  
I'm using basic authentication with REST API but sometime server response 401 Unauthorized as:

`401 Unauthorized {"error":{"root_cause":[{"type":"security_exception","reason":"unable to authenticate user [xxxxxxxxx] for REST request [xxxxxxxx]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"unable to authenticate user [xxxxxxxx] for REST request [xxxxxxxx]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}`

Have anyone got the same issue? Please give me an advice to work around with this one.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 10, 2021, 2:10am UTC](https://discuss.elastic.co/t/intermittently-failed-with-401-unauthorized/288835/2 "2021-11-10T02:10:16Z")

</div>

Welcome to our community! 😃

Where do you see that error?

---

<div class="post-metadata">

**Author:** ![John\_Luong\_Nhat\_Truo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john_luong_nhat_truo/32/77625_2.png) [@John\_Luong\_Nhat\_Truo](https://discuss.elastic.co/u/John_Luong_Nhat_Truo)\
**Post date:** [November 10, 2021, 2:16am UTC](https://discuss.elastic.co/t/intermittently-failed-with-401-unauthorized/288835/3 "2021-11-10T02:16:34Z")

</div>

Hi,  
I got this error sometime when i sent POST request to Elastic server.

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [November 10, 2021, 5:32am UTC](https://discuss.elastic.co/t/intermittently-failed-with-401-unauthorized/288835/4 "2021-11-10T05:32:15Z")

</div>

It's likely your logs will contain more information.  
For security reasons, if authentication fails we don't provide the root cause over HTTP (because the user isn't authenticated).

---

<div class="post-metadata">

**Author:** ![John\_Luong\_Nhat\_Truo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john_luong_nhat_truo/32/77625_2.png) [@John\_Luong\_Nhat\_Truo](https://discuss.elastic.co/u/John_Luong_Nhat_Truo)\
**Post date:** [November 10, 2021, 6:13am UTC](https://discuss.elastic.co/t/intermittently-failed-with-401-unauthorized/288835/5 "2021-11-10T06:13:37Z")

</div>

Hi Timv,  
Yes, i think so. But the authentication almost success with the same user/password. It's sometime failed and make me confuse. So i would to to ask if anyone got the same issue and how we can fix it.

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [November 10, 2021, 7:24am UTC](https://discuss.elastic.co/t/intermittently-failed-with-401-unauthorized/288835/6 "2021-11-10T07:24:22Z")

</div>

Without logs we don't know what the real issue is, so it's impossible for anyone to know whether they have the same issue.

Logs will really help with getting you to a solution.

---

<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:** [December 8, 2021, 7:25am UTC](https://discuss.elastic.co/t/intermittently-failed-with-401-unauthorized/288835/7 "2021-12-08T07:25:08Z")

</div>

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