Flask app always binds to port 8080 despite correct Procfile and PORT configuration
bmorethangood-netizen
HOBBYOP

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?

$10 Bounty

6 Replies

Railway
BOT

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!


irazvan2745
FREE

5 months ago

Hey, you need to change the port on railpack


case
PRO

5 months ago

@bmorethangood-netizen which Build method are you using? E.g. Dockerfile, Railpacks, Nixpacks, etc?

https://docs.railway.com/guides/build-configuration


Anonymous
HOBBY

5 months ago

You can change the port value from here in railway

Attachments


eetezadi
HOBBY

5 months ago

Do you have a custom start command in settings that overwrites the Procfile? Happened to me...


bmorethangood-netizen
HOBBYOP

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


Loading...