# Timeout exception when querying for users

**URL:** <https://community.auth0.com/t/timeout-exception-when-querying-for-users/28422>\
**Category:** Get Help\
**Tags:** user-search, management-api\
**Created:** [July 23, 2019, 10:10pm UTC](https://community.auth0.com/t/timeout-exception-when-querying-for-users/28422 "2019-07-23T22:10:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![smajeti](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/smajeti/32/13568_2.png) [@smajeti](https://community.auth0.com/u/smajeti)\
**Post date:** [July 23, 2019, 10:10pm UTC](https://community.auth0.com/t/timeout-exception-when-querying-for-users/28422/1 "2019-07-23T22:10:33Z")

</div>

Hi,  
Im trying to retrieve all the users whose user\_id starts with a predefined prefix. I am always receiving HTTP 503, query exceeded timeout exception. I made sure we are requesting for a single page of results, which is way less than the prescribed limit of 1000.  
I also looked into creating an export users job but it doesn’t allow filtering based on user\_id prefix.  
Can anyone suggest me how to fix this issue?  
Following is the Request/Response for reference:

Request: https://auth0\_endpoint/api/v2/users?per\_page=10&page=0&q=user\_id:samlp|saml-\* AND updated\_at:[2019-05-21T18:29:04.286Z TO 2019-06-21T20:29:04.286Z]&search\_engine=v3

Response:  
{  
“statusCode”: 503,  
“error”: “Service Unavailable”,  
“message”: “The query exceeded the timeout. Please try refining your search criteria. See [User Search Best Practices - Auth0 Docs](https://auth0.com/docs/best-practices/search-best-practices)”  
}

---

<div class="post-metadata">

**Author:** ![jonathanjohnston725](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jonathanjohnston725/32/12921_2.png) [@jonathanjohnston725](https://community.auth0.com/u/jonathanjohnston725)\
**Post date:** [July 24, 2019, 12:49pm UTC](https://community.auth0.com/t/timeout-exception-when-querying-for-users/28422/2 "2019-07-24T12:49:04Z")

</div>

This would abort the query to save resources, and for example throw a Timeout exception[.](https://www.tellpopeyes.me/)

---

<div class="post-metadata">

**Author:** ![smajeti](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/smajeti/32/13568_2.png) [@smajeti](https://community.auth0.com/u/smajeti)\
**Post date:** [July 24, 2019, 4:35pm UTC](https://community.auth0.com/t/timeout-exception-when-querying-for-users/28422/3 "2019-07-24T16:35:41Z")

</div>

is there a way to retrieve the list of users Im looking for?

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [July 24, 2019, 4:41pm UTC](https://community.auth0.com/t/timeout-exception-when-querying-for-users/28422/4 "2019-07-24T16:41:26Z")

</div>

Hello @smajeti and @jonathanjohnston725! I am currently checking with one of our senior team members to see If I can find out an answer for you. I will reply back with what I find, thanks!

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [July 24, 2019, 4:50pm UTC](https://community.auth0.com/t/timeout-exception-when-querying-for-users/28422/5 "2019-07-24T16:50:58Z")

</div>

@smajeti after checking with one of our senior team members they recommend reducing the time being searched for. Please let me know if this helps you proceed forward, otherwise we can take a deeper look at other possibilities. Thank you.

---

<div class="post-metadata">

**Author:** ![smajeti](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/smajeti/32/13568_2.png) [@smajeti](https://community.auth0.com/u/smajeti)\
**Post date:** [July 24, 2019, 5:04pm UTC](https://community.auth0.com/t/timeout-exception-when-querying-for-users/28422/7 "2019-07-24T17:04:15Z")

</div>

@James.Morrison  
I changed my query from  
q=user\_id:samlp|saml-\* AND updated\_at:[2019-05-21T18:29:04.286Z TO 2019-06-21T20:29:04.286Z] to q=updated\_at:[2019-05-21T18:29:04.286Z TO 2019-06-21T20:29:04.286Z] AND user\_id:samlp|saml-\*  
and it works fine.

Looks like the sorted key was based on timestamp and service manually filters the results based on the id prefix before returning the results.

Thank you so much for your help. Looks like Im currently unblocked.

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [July 24, 2019, 5:09pm UTC](https://community.auth0.com/t/timeout-exception-when-querying-for-users/28422/8 "2019-07-24T17:09:48Z")

</div>

I’m happy to hear it all came together, have a fantastic day!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 8, 2019, 5:14pm UTC](https://community.auth0.com/t/timeout-exception-when-querying-for-users/28422/9 "2019-08-08T17:14:21Z")

</div>

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