🛑 502 Bad Gateway after fixing $PORT issue on Django + Gunicorn Railway Deployment
bhaskardwivedi
HOBBYOP

10 months ago

Hi,

After fixing the $PORT environment issue, now my Django backend deployment is crashing with a 502 Bad Gateway error on Railway. The logs show that the container starts but doesn’t serve the app properly.

My setup:

  • Django backend (with backend.wsgi:application)
  • Gunicorn used with command: python manage.py migrate && gunicorn backend.wsgi:application --log-file -

Here is my gitbhub repo link - https://github.com/Bhaskardwivedi/portfolio-backend

bash

CopyEdit

Attachments

$10 Bounty

3 Replies

Railway
BOT

10 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!


clashing
FREE

10 months ago

Checked the DockerFile that you have attached in the GitHub repo, try changing it:

CMD ["gunicorn", "backend.wsgi:application", "--bind", "0.0.0.0:${PORT:-8000}"]

Just the last line has to be changed 🙌 (this tells Gunicorn to listen on all interfaces and the port defined in the Railway environment variable)

If that helps, mark this as the solution


clashing

Checked the DockerFile that you have attached in the GitHub repo, try changing it: `CMD ["gunicorn", "backend.wsgi:application", "--bind", "0.0.0.0:${PORT:-8000}"]` Just the last line has to be changed 🙌 (this tells Gunicorn to listen on all interfaces and the port defined in the Railway environment variable) If that helps, mark this as the solution

clashing
FREE

9 months ago

bhaskardwivedi, any update for this issue!


Welcome!

Sign in to your Railway account to join the conversation.

Loading...