DataTalksClub / DataTalksClub/faq
[FAQ] Why does my FastAPI backend return "detail: Not Found" at localhost:8000?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7
- Forks
- 19
- Avg merge
- 3d 20h
- Merged PRs (30d)
- 9
Description
Course
ai-dev-tools-zoomcamp
Question
Why does http://localhost:8000 return {"detail":"Not Found"} after I start my FastAPI backend?
Answer
Your FastAPI server is running correctly. The {"detail":"Not Found"} response means that the application has no endpoint defined for the root path (/).
Open the interactive API documentation instead:
http://localhost:8000/docs
Or call an endpoint that your application defines, for example:
http://localhost:8000/v1/household/state
If you want http://localhost:8000/ to show a response, add a root route to your FastAPI application:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def health_check():
return {"message": "API is running"}
FastAPI only responds to paths you define with route decorators such as @app.get("/"). When no matching route exists, it returns a 404 Not Found response with {"detail":"Not Found"}.
Checklist
- I have searched existing FAQs and this question is not already answered
- The answer provides accurate, helpful information
- I have included any relevant code examples or links
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the FAQ question and answer in this issue, including the /docs and /v1/household/state examples. Verify that the FastAPI behavior and root-route example are accurate, then consider the FAQ complete when the explanation, links, and code example clearly answer why localhost:8000 returns 404.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100