a year ago
We are experiencing persistent healthcheck failures with our FastAPI application on Railway. Despite multiple attempts to fix the issue, the healthcheck continues to fail, preventing successful deployment of the application.
Configuration Details
- Application: FastAPI API (Python)
- Railway Configuration:
toml CopyInsert
[deploy] startCommand = "uvicorn api.main:app --host 0.0.0.0 --port $PORT" healthcheckPath = "/railway-health" healthcheckTimeout = 300 healthcheckInterval = 15 healthcheckGracePeriod = 60
3. Healthcheck Endpoint:
python CopyInsert
@app.get("/railway-health") def railway_healthcheck(): """Extremely simple endpoint for Railway healthcheck""" return {"status": "ok"}
Solution Attempts
- Dedicated healthcheck endpoint implementation:
- Created a simple
endpoint that always returns a 200 OK status/health- Later created an even simpler
endpoint specifically for Railway/railway-health- Both endpoints are independent of any environment variables or external services
- Application resilience improvements:
- Modified the
function to returnget_supabase_client()instead of throwing exceptions when credentials are unavailableNone- Updated endpoints to explicitly check if the Supabase client is available
- Implemented proper error handling with 503 status when services are unavailable
- Railway configuration adjustments:
- Updated
railway.tomlto use the dedicated healthcheck endpoint - Increased healthcheck timeout to 300 seconds
- Added a 15-second interval between checks
- Configured a 60-second grace period for initialization
- Updated
- Local testing:
- Tested the healthcheck endpoints locally and confirmed they are working correctly
- Verified that the application starts without errors even without Supabase environment variables
6 Replies
a year ago
We would like to request assistance to:
- Verify if there is any issue with the healthcheck configuration in
railway.toml - Confirm if Railway is trying to access the correct endpoint for the healthcheck
- Suggest additional configurations that might solve the problem
- Provide detailed logs of the deployment attempt to help with debugging
Thank you in advance for your assistance.
a year ago
What you mean? The link or the files?
mvpleilao
What you mean? The link or the files?
a year ago
The link to the GitHub repository.
a year ago
Hey guys!
Was a port conflict.
Somehow I hardcode it and then revert again to a variable in Railway and it worked fine.
a year ago
Sounds good, let us know if you have any other issues!
Status changed to Awaiting User Response Railway • 11 months ago
Status changed to Solved sarahkb125 • 11 months ago
