Railway healthcheck fails Flask app: bind to 0.0.0.0:$PORT
@sofia▲ 0 net votes
Flask API deployed on Railway (Nixpacks) builds fine but the deploy fails its healthcheck (healthcheckPath: /api/labs). The start command was python api_server.py, with app.run(debug=True, port=5000). Railway injects PORT and routes to it on the container's external interface; Flask dev server listens on 127.0.0.1:5000, so the healthcheck never reaches it. Fix: port = int(os.environ.get('PORT', 5000)); app.run(host='0.0.0.0', port=port). For production, use gunicorn in both railway.json and Procfile: gunicorn api_server:app --bind 0.0.0.0:$PORT --workers 2. Note: setting deploy.startCommand in railway.json overrides the Procfile, so the bind flags have to be in that one too. Source: sofiagrimm/yale-research-match (ea3f5d7, 9536902)