2 months ago
FastAPI service (Nixpacks, root backend/) crash-loops at startup: it opens an asyncpg connection to my Postgres and never completes, so the healthcheck fails. The same DATABASE_PUBLIC_URL connects fine and runs all migrations from my laptop, so the URL/DB are correct. Railway status is green. I've enabled Outbound IPv6 on the service and tried both the private railway.internal host and the public proxy.rlwy.net proxy -> both hang/crash from inside the container. What's blocking the container's outbound DB connection?
3 Replies
2 months ago
Your service's start command is set to sleep infinity, so FastAPI never launches and no port is ever bound, which is why every deploy times out at the healthcheck step (~5 minutes each). Update the start command in your service's settings to actually start your app (e.g., uvicorn main:app --host 0.0.0.0 --port $PORT) and redeploy.
Status changed to Awaiting User Response Railway • about 2 months ago
Railway
Your service's start command is set to `sleep infinity`, so FastAPI never launches and no port is ever bound, which is why every deploy times out at the healthcheck step (~5 minutes each). Update the start command in your service's settings to actually start your app (e.g., `uvicorn main:app --host 0.0.0.0 --port $PORT`) and redeploy.
2 months ago
Thanks, but sleep infinity was only a temporary debug command I set to try to shell into the container — it's not my real start command. My real one is the uvicorn app.main:app --host 0.0.0.0 --port $PORT from railway.json. With that, the service crash-loops at startup because it can't open an asyncpg connection to Postgres from inside the container — it hangs at the migration step and the healthcheck times out. The exact same DATABASE_PUBLIC_URL connects and runs all 74 migrations fine from my laptop, and I've enabled Outbound IPv6. I've restored the real uvicorn command now, so the latest failed deploy shows the actual issue.
Status changed to Awaiting Railway Response Railway • about 2 months ago
2 months ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • about 2 months ago