# How BackgroundTasks FastAPI works in HuggingFace Space

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-backgroundtasks-fastapi-works-in-huggingface-space%2F109597%3E%5C
**Category:** Spaces\
**Created:** [October 1, 2024, 10:34am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-backgroundtasks-fastapi-works-in-huggingface-space%2F109597 "2024-10-01T10:34:59Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [October 2, 2024, 9:48am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-backgroundtasks-fastapi-works-in-huggingface-space%2F109597%2F4 "2024-10-02T09:48:24Z")

</div>

Hello. Hmmm… I guess I was wrong.  
I thought HF’s Spaces port was **only 7860** available by default?  
Maybe the one that has to be set in the YAML part of the README.md.  
In your case, I don’t think the request is getting through to the Spaces program because even the error log isn’t changing.

@not-lain Do you know anything about that?

> **[Spaces Configuration Reference](https://huggingface.co/docs/hub/spaces-config-reference)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> [@FastAPI Routing Issue in Hugging Face Spaces](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffastapi-routing-issue-in-hugging-face-spaces%2F54962)%3A
>
> Hello everyone, I’ve deployed a FastAPI application on Hugging Face Spaces. Everything seems to be running smoothly, and there are no errors in the logs. However, when I try to access my endpoints via a browser or tools like Postman, I’m getting a “404 error” or a “Cannot POST” error. Here’s a brief overview of my setup: I have a FastAPI route defined as @app.get("/check\_request") and another one as @app.post("/recommend"). My Dockerfile specifies the CMD as CMD ["uvicorn", "app:app", "--hos…

---

_[View the full topic](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-backgroundtasks-fastapi-works-in-huggingface-space%2F109597)._
