5 months ago
I'm trying to deploy a Flask app but Railway keeps binding to port 8080 instead of using the $PORT environment variable. My setup: - Repository: Python Flask app - Procfile contains: web: gunicorn main:app --bind 0.0.0.0:$PORT - main.py ends with: port = int(os.environ.get('PORT', 5001)); app.run(host='0.0.0.0', port=port, debug=False) Deploy logs show: - "Starting gunicorn 21.2.0" - "Listening at: http://0.0.0.0:8080" The app appears ACTIVE but returns 404 on all endpoints. I've tried: - Deleting and recreating the project - Verifying Procfile is named exactly "Procfile" (capital P) - Confirming all files are correct in GitHub Why is Railway defaulting to 8080 instead of reading $PORT? What am I missing?
6 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
Hey, you need to change the port on railpack
5 months ago
@bmorethangood-netizen which Build method are you using? E.g. Dockerfile, Railpacks, Nixpacks, etc?
5 months ago
Do you have a custom start command in settings that overwrites the Procfile? Happened to me...
5 months ago
Thanks everyone for the suggestions! I ended up resolving this by switching to Render instead of Railway. The issue seemed to be Railway-specific port binding behavior that persisted despite trying the various solutions mentioned. For anyone else hitting similar Railway port issues, Render worked immediately with the same Procfile configuration. Appreciate the community support
