6 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
bashCopyEdit
Attachments
3 Replies
6 months ago
Hey there! We've found the following might help you get unblocked faster:
🧵 502 Bad Gateway error even when deployment was successful
🧵 502 Bad Gateway error despite successful container startup
If you find the answer from one of these, please let us know by solving the thread!
6 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
6 months ago
bhaskardwivedi, any update for this issue!