13 days ago
Need help with Railway + FastAPI
My app works fine on localhost — all routes like /webhook work.
But on Railway, only /health works — everything else shows 404 Not Found.
No errors in logs, app starts fine.
I’m using uvicorn main:app.
Maybe the railway.toml or start command is wrong?
Example:
uvicorn main:app --host 0.0.0.0 --port $PORT
Any idea why only /health works?
1 Replies
13 days ago
The fact that /health works confirms the app is running and accessible, so this is an application-level routing issue, not a Railway platform problem.
Is your FastAPI app using any routers or subpath mounting? If routes are mounted on a subpath (like /api/v1/webhook), you need to access them accordingly.
i am trying but to acess with like .api/v1 etc but still not working and showing the not found even its works perfectly on local host
I understand, is there a way you can show us one route as an example and the configuration you have to add that route to the main fastapi app
Here’s one example route from my code:
In app.py:
from backend.routes import socialwebhooks app.includerouter(social_webhooks.router, prefix="/api/social")
Example route inside social_webhooks.py:
@router.get("/test")
async def testwebhookrouter():
return {"status": "success", "message": "Social webhooks router is loaded!"}
Locally this works fine at:
http://127.0.0.1:8000/api/social/test
But on Railway, I get a 404 at:
https://.up.railway.app/api/social/test
Only /health works on Railway.
Can you please confirm if I need to adjust ROOT_PATH or prefix handling on Railway?
@ranuare @Railway
Can you try to use the prefix inside social_webhooks, like this:
router = APIRouter(
prefix="/api/social"
)
Instead of adding it in the app.py
Hey, I tried moving the prefix inside social_webhooks.py like this:
router = APIRouter(prefix="/api/social")
but it still didn’t work.
Only /health route works on Railway — all other routes (like /api/social/webhook) give 404.
My main file is app.py (not main.py).
If you go to your fastapi service, click on the last deployment and go to details tab you can see what railpack is using
Check if its using the app.py as the main file, if not, you can add a custom start command

Do you have the health path inside app.py?
bro i understand why its happening its my own fault like for accesing through url
