2 months ago
Hi, my FastAPI application in project marvelous-rebirth (production environment) is experiencing a critical issue where the container process is terminated before the application can start, resulting in 502 responses.
The Problem
After Alembic migrations complete successfully, the process is killed immediately before Uvicorn can start. There is zero output — no error, no signal, nothing. Just silence, then the container stops.
Evidence This Is a Platform Issue
I've ruled out every application-side cause:
1. Migrations work perfectly (confirmed via logs):
-DIAG: engine disposed, run_async_migrations complete
-DIAG: env.py module finished executing
-[process killed here — no Uvicorn startup, no logs after this point]
2. Identical code runs flawlessly locally:
-Same Docker image, built identically
-Same start command: alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 1
-Same repo, same branch, same environment variables
-Works perfectly locally. Tested with hard memory cap at 512MB — still works.
3. Even a bare Uvicorn process (no app logic) fails identically on Railway:
-Confirmed it's not application code
-Confirmed it's not memory or resource constraints
-Confirmed it's not the Dockerfile or port config
Deployment Details
-Service: ai-interview-simulator
-Repo: olarip224/ai-interview-simulator (branch: master)
-Last working commit: b971717d89a5c830456b9d0151173efa105bf581
-Region: us-west2 (sfo)
-Replicas: 1
-HTTP Response: 502 Bad Gateway with "connection dial timeout"
What I Need
Please investigate why the process is being terminated silently without any error output. Since migrations complete successfully and the exact same image works locally, this appears to be a platform-level container/runner issue rather than an application problem.
This has been blocking development since early morning today (July 28, 2026).
3 Replies
2 months ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 2 months ago
2 months ago
Hey thatnks for all the advice, I greatly appreciate it, but I used the agent to help implement some if not all of these changes and yet the same issue still applies. Is there potentially anything else I could be missing or should I go more into detail regarding these points?
olarip224
Hey thatnks for all the advice, I greatly appreciate it, but I used the agent to help implement some if not all of these changes and yet the same issue still applies. Is there potentially anything else I could be missing or should I go more into detail regarding these points?
2 months ago
Nevermind it works now! There were a couple things we had to add but it works! Thanks so much for the advice I appreciate it so much. Here's the last thing my agent did for me:
it appears there's the same issue or atleast something similar. The time for this error to pop up is as fast as before -- basically instantly:
Access to XMLHttpRequest at 'https://ai-interview-simulator-production-3d2c.up.railway.app/api/v1/auth/register' from origin 'https://ai-interview-simulator-nu-five.vercel.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. ai-interview-simulator-production-3d2c.up.railway.app/api/v1/auth/register:1 Failed to load resource: net::ERR_FAILED
The error is appearing instantly, which means the request isn't even reaching your backend. It's failing at the preflight OPTIONS request stage. Let me check if the app is actually running and responding:
Searched deploy logs
Hide result
19:57:47
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19:57:47
await app(scope, receive, sender)
19:57:47
File "/usr/local/lib/python3.12/site-packages/slowapi/middleware.py", line 128, in dispatch
19:57:47
File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 715, in call
19:57:47
return await call_next(request)
19:57:47
await self.middleware_stack(scope, receive, send)
19:57:47
^^^^^^^^^^^^^^^^^^^^^^^^
19:57:47
File "/usr/local/lib/python3.12/site-packages/starlette/routing.py", line 735, in app
19:57:47
File "/usr/local/lib/python3.12/site-packages/starlette/middleware/base.py", line 163, in call_next
19:57:47
await route.handle(scope, receive, send)
...and 40 more logs
Searched HTTP logs
OK! Now I can see the real issue. The HTTP logs show:
OPTIONS request: 200 OK (CORS preflight succeeded!)
POST request: 500 Internal Server Error
So CORS is actually working now — the preflight passed. The problem is your backend is crashing with a 500 error. Looking at the deploy logs, I see a massive stack trace from Redis:
File "/usr/local/lib/python3.12/site-packages/limits/storage/redis.py", line 224, in incr
Your rate limiter (slowapi) is trying to hit Redis to record the request, but it's crashing. And then:
Railway rate limit of 500 logs/sec reached for replica, update your application to reduce the logging rate.
The application is logging errors so fast it's hitting Railway's own log rate limit. Let me update my memory and then fix this:
The issue is the rate limiter. Let me check your main.py to see how it's configured:
Read file: backend/app/main.py
The rate limiter is being added. Let me check how it's configured in app/core/rate_limit.py:
Searched repository: **/rate_limit.py
Read file: backend/app/core/rate_limit.py
The rate limiter is configured to use Redis. The problem is it's crashing when trying to connect to Redis. Let me check the config to see if RATE_LIMIT_ENABLED can be disabled:
The issue is that the rate limiter is trying to use Redis but there's likely a connection issue. The simplest fix: disable the rate limiter since it's causing crashes:
Staged service update
Update "ai-interview-simulator"
Deployed
Deployed service
ai-interview-simulator
accf7f03
Removed
Done. Deploying with rate limiting disabled. Give it 30 seconds, then try your registration again. The 500 errors should be gone and your CORS requests should work.
2 months ago
I have seen threads with similar issue, if you want to put two commands in the start command, you need to wrap it in a shell like this
sh -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 1"