# Issue with FlaskAPI in a Private Space After Sleeping Mode

**URL:** <https://discuss.huggingface.co/t/issue-with-flaskapi-in-a-private-space-after-sleeping-mode/147150>\
**Category:** Beginners\
**Created:** [March 24, 2025, 8:05am UTC](https://discuss.huggingface.co/t/issue-with-flaskapi-in-a-private-space-after-sleeping-mode/147150 "2025-03-24T08:05:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kashtan](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@Kashtan](https://discuss.huggingface.co/u/Kashtan)\
**Post date:** [March 24, 2025, 8:05am UTC](https://discuss.huggingface.co/t/issue-with-flaskapi-in-a-private-space-after-sleeping-mode/147150/1 "2025-03-24T08:05:56Z")

</div>

Hey everyone,

I’m facing an issue with my FlaskAPI running in a private Hugging Face Space. I’ve set the space to enter sleeping mode after some time to save resources. However, when I try to wake it up after a few hours by sending a GET/POST request, I get a 404 error.

I suspect this might be related to the spaces-jwt token refreshing periodically. I found this thread discussing JWT expiration settings:  
[https://discuss.huggingface.co/t/how-to-modify-the-fastapi-jwt-token-expiration-setting-issued-by-huggingface/78593](https://discuss.huggingface.co/t/how-to-modify-the-fastapi-jwt-token-expiration-setting-issued-by-huggingface/78593)

However, when I try to send the GET request, I get a “Sorry, we can’t find the page you are looking for” error. I’m not sure if my issue is due to an incorrect setup, the token expiration, or something related to the sleeping mode.

My Space: idkash1/Detect\_Edits\_in\_AI-Generated\_Text

Would appreciate any insights or advice.  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [March 24, 2025, 11:24am UTC](https://discuss.huggingface.co/t/issue-with-flaskapi-in-a-private-space-after-sleeping-mode/147150/2 "2025-03-24T11:24:26Z")

</div>

Hmm… It works. I think it’s sleeping on its own, but I wonder if it won’t happen unless you explicitly put it into sleep mode.

```py
HF_TOKEN = "hf_my_pro_token"
import requests
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
url = "https://huggingface.co/api/spaces/John6666/gradio-server-test/jwt"
result = requests.get(url, headers=headers).json()
print(result)
# {'token': '...

```

---

<div class="post-metadata">

**Author:** ![Kashtan](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@Kashtan](https://discuss.huggingface.co/u/Kashtan)\
**Post date:** [March 24, 2025, 2:42pm UTC](https://discuss.huggingface.co/t/issue-with-flaskapi-in-a-private-space-after-sleeping-mode/147150/3 "2025-03-24T14:42:19Z")

</div>

I couldn’t see it because it was a private space, so I changed it to public and found the token via the API.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [March 24, 2025, 2:46pm UTC](https://discuss.huggingface.co/t/issue-with-flaskapi-in-a-private-space-after-sleeping-mode/147150/4 "2025-03-24T14:46:04Z")

</div>

In my case, the script above worked in Private Space. So, I think it’s possible that there’s something wrong with the state of the Spaces or it’s a server glitch.

A few hours ago, an error was reported on HF Discord for a completely different matter, and it fixed itself. It might be something similar.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](https://discuss.huggingface.co/u/system)\
**Post date:** [March 25, 2025, 2:46am UTC](https://discuss.huggingface.co/t/issue-with-flaskapi-in-a-private-space-after-sleeping-mode/147150/5 "2025-03-25T02:46:10Z")

</div>

Closed on March 25, 2025, 2:46am UTC

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