5 months ago
Problem Description:
My Flask application starts successfully but Railway immediately stops the container within seconds. The application appears to be running correctly (gunicorn starts, binds to port 8080, creates workers) but Railway terminates it without explanation.
Current Behavior:
Starting Container
[2025-09-22 19:07:38 +0000] [2] [INFO] Starting gunicorn 21.2.0
[2025-09-22 19:07:38 +0000] [2] [INFO] Listening at: http://0.0.0.0:8080 (2)
[2025-09-22 19:07:38 +0000] [2] [INFO] Using worker: sync
[2025-09-22 19:07:38 +0000] [3] [INFO] Booting worker with pid: 3
Stopping Container
What We've Tried:
1. Configuration Files - Tested with Procfile, nixpacks.toml, railway.json, railway.toml - Railway appears to ignore all configuration files and runs python app.py regardless
2. Port Configuration - Confirmed app correctly uses Railway's PORT environment variable (8080), tested various port binding methods
3. Production Server - Switched from Flask development server to gunicorn with various configurations:
- gunicorn app:app --bind 0.0.0.0:8080
- Added timeout, keep-alive, preload flags
- Tested different worker counts
4. Dependency Management - Simplified requirements.txt to minimal Flask + gunicorn
5. App Simplification - Created minimal Flask app with just "Hello World" route and health check endpoint
Current App Configuration:
- Language: Python 3.11.13
- Framework: Flask 3.0.3
- Server: Gunicorn 21.2.0
- Port: Uses Railway's PORT environment variable (8080)
- Endpoints: Root route and /health endpoint
- Repository: https://github.com/austin-roon/projects
Environment Variables Detected:
PORT: 8080
RAILWAY_SERVICE_NAME: projects
RAILWAY_ENVIRONMENT: production
Questions:
1. Why does Railway stop a successfully running gunicorn server?
2. Are there specific health check requirements we're missing?
3. Are there account limitations causing this behavior?
4. Does Railway require specific response times or endpoints for health checks?
5. Is there a way to see why Railway decides to stop the container?
Expected Behavior:
The gunicorn server should remain running and serve the Flask application on the generated Railway domain.
Any guidance on Railway-specific requirements or debugging steps would be greatly appreciated.
2 Replies
5 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
5 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 5 months ago
5 months ago
Hey there! Would love some more logs if possible to learn some info.
Is your service binding to the correct port? (sometimes people hardcode and print what it should bind to but sometimes put it in wrongly)
Are your healthchecks configured to the correct paths?
On that, does the healthcheck path you're pinging return a 200 response code?