Django : Server Error

ndhlovu1TRIAL

a year ago

Hi,

I am currently having a new and clean django project that I'd like to deploy.
I get a successful deployment message however, I keep getting a server message error. I have created the railway.json file however. I still seem to not get this project to work.

Please help.

7 Replies

Hey ndhlovu1!

Are you using gunicorn?

If you do and you are setting the port like this:

gunicorn someapp.wsgi --bind 0.0.0.0:8000

Remember that Railway uses the PORT environment variable. So your gunicorn command should look something like this

Currently I'm using this and is working as expected:

gunicorn someapp.wsgi --workers 2 --forwarded-allow-ips "*"

Cheers

Leo


ndhlovu1TRIAL

a year ago

Hi Leo, Thanks for responding!

I followed the https://github.com/railwayapp-templates/django/blob/main/railway.json and a previous thread on deploying with gunicorn added in the railway.json file and having been uploaded.

However this is interestingly working for me. also, the command you are using, can I use this in the railway.json file of my project?


ndhlovu1TRIAL

a year ago

I also, keep getting the error :

python: can't open file 'manage.py': [Errno 2] No such file or directory and I am lost as to where this error is coming from


Hey!

I guess you can adapt the command to:

"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi --workers 2 --forwarded-allow-ips '*'",

If that does not work you might need to escape the " by doing --forwarded-allow-ips \"*\""


About the manage.py error. Confirm that the manage.py file is at the same level as the railway.json file, otherwise you will need to update the paths on the command or change the directory structure of your project.


a year ago

Hey Leo, could you do me a favour and enable your public profile - https://railway.app/account


Hey! Sure


Django : Server Error - Railway Help Station