Issue Deploying Django App with Gunicorn on Railway
Anonymous
TRIALOP

2 years ago

It's been a few days of trying to get this up for some production tests but I'm having issues getting it to launch on railway. Everything works great locally in the debug environment 'python manage.py runserver'. I'm still relatively new regarding web server deployment but from what I read railway was a good starting point for my use case but I'm still unsure.

I've added all the necessary files for deployment, changed my settings for production, and hidden my variables in the environment (I have them on railway too). Requirements, Runtime, procfile and gunicorn.conf. For some reason, I always seem to encounter an issue with the docker image building or it says no start-up command and I'm not sure what command would be required while I have the procfile.

Any help would be appreciated and if anyone has the time to help me out more in-depth, I'm willing to pay if you can help me solve my issue.

174 Replies

brody
EMPLOYEE

2 years ago

if your Procfile doesn't have a capital P it wont be detected.


Anonymous
TRIALOP

2 years ago

1234180008180973800


brody
EMPLOYEE

2 years ago

what are its contents?


Anonymous
TRIALOP

2 years ago

release: python manage.py migrate
web: gunicorn dragon.wsgi -c gunicorn.conf.py


brody
EMPLOYEE

2 years ago

i think it would be best to delete the heroku Procfile and use a railway.json file instead -


Anonymous
TRIALOP

2 years ago

Ill try that


Anonymous
TRIALOP

2 years ago

So it looks like it deployed correctly but it failed to respond


Anonymous
TRIALOP

2 years ago

1234181485767037200


Anonymous
TRIALOP

2 years ago

could it be my port


Anonymous
TRIALOP

2 years ago

with the conf file


brody
EMPLOYEE

2 years ago

yes, send your gunicorn.conf please


Anonymous
TRIALOP

2 years ago

bind = "0.0.0.0:8000"
workers = 3
timeout = 120


brody
EMPLOYEE

2 years ago

remove the bind line


Anonymous
TRIALOP

2 years ago

okay


Anonymous
TRIALOP

2 years ago

Same thing


Anonymous
TRIALOP

2 years ago

1234182677985362200


Anonymous
TRIALOP

2 years ago

it selected a port tho


Anonymous
TRIALOP

2 years ago

Invalid HTTPHOST header: 'dragon-production.up.railway.app'. You may need to add 'dragon-production.up.railway.app' to ALLOWEDHOSTS.


Anonymous
TRIALOP

2 years ago

oo


brody
EMPLOYEE

2 years ago

please be more specfic when you say there is an error


Anonymous
TRIALOP

2 years ago

this is the first actual error ive gotten so. Progress lol


Anonymous
TRIALOP

2 years ago

ima try to add that


Anonymous
TRIALOP

2 years ago

I appreciate your time.


Anonymous
TRIALOP

2 years ago

I've tried to deploy with he cli as it seems faster but I always run in to this error Failed to stream build logs: TLS error: webpki error: MissingOrMalformedExtensions Failed to stream deploy logs: TLS error: webpki error: MissingOrMalformedExtensions


brody
EMPLOYEE

2 years ago

thats an issue with your os, but the code would have still been uploaded


Anonymous
TRIALOP

2 years ago

1234183862796423200


Anonymous
TRIALOP

2 years ago

I thought soo I was gonna run a virtual env for it but I figured if I'm launching in railway I don't need to


brody
EMPLOYEE

2 years ago

are you using a custom domain?


Anonymous
TRIALOP

2 years ago

no just he railway generated one


Anonymous
TRIALOP

2 years ago

1234184350879187000


brody
EMPLOYEE

2 years ago

your code and or gunicorn is sending redirects when it shouldnt


brody
EMPLOYEE

2 years ago

try adding --forwarded-allow-ips "*" to your gunicorn start command


Anonymous
TRIALOP

2 years ago

1234184962706505700


Anonymous
TRIALOP

2 years ago

would it be any of this


brody
EMPLOYEE

2 years ago

no, please read the message again


Anonymous
TRIALOP

2 years ago

okay i will try that


Anonymous
TRIALOP

2 years ago

WOOO


Anonymous
TRIALOP

2 years ago

okay sooo


Anonymous
TRIALOP

2 years ago

--forwarded-allow-ips "* what does it do


Anonymous
TRIALOP

2 years ago

is that an usecure thing i should worrie about


brody
EMPLOYEE

2 years ago

did it fix the redirect issue?


Anonymous
TRIALOP

2 years ago

Yes


brody
EMPLOYEE

2 years ago


Anonymous
TRIALOP

2 years ago

I have another issue too i see


Anonymous
TRIALOP

2 years ago

none of djangos static files are found


Anonymous
TRIALOP

2 years ago

1234186788289904600


brody
EMPLOYEE

2 years ago

whats your current railway.json in use?


Anonymous
TRIALOP

2 years ago

{ "$schema": "https://railway.app/railway.schema.json", "build": { "builder": "NIXPACKS" }, "deploy": { "startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn dragon.wsgi --forwarded-allow-ips '*'", "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 10 } }


brody
EMPLOYEE

2 years ago

send your settings.py file please


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

Do you prefer bmac or do you want some crypto >?


brody
EMPLOYEE

2 years ago

use these -


brody
EMPLOYEE

2 years ago

you dont need to send me anything, but thank you


Anonymous
TRIALOP

2 years ago

Well, I think you deserve something. You've been a great help.


Anonymous
TRIALOP

2 years ago

what you do want 😄


Anonymous
TRIALOP

2 years ago

steam card or somthing


brody
EMPLOYEE

2 years ago

bmac if you insist


Anonymous
TRIALOP

2 years ago

Sounds good


Anonymous
TRIALOP

2 years ago

Enjoy your trains


brody
EMPLOYEE

2 years ago

thank you very much


Anonymous
TRIALOP

2 years ago

I may need a hand in the future so I'm gonna add you 😄


Anonymous
TRIALOP

2 years ago

nothing is free in this world and your time is valuable so I will pay for your services.


Anonymous
TRIALOP

2 years ago

?: (staticfiles.W004) The directory '/app/static' in the STATICFILES_DIRS setting does not exist.

125 static files copied to '/app/staticfiles'.


brody
EMPLOYEE

2 years ago

i appreciate that but i wouldn’t be here if i wanted the people i help to pay


Anonymous
TRIALOP

2 years ago

i feel like I'm missing something


brody
EMPLOYEE

2 years ago

might be easier if you could share your repo?


Anonymous
TRIALOP

2 years ago

Whats your git


brody
EMPLOYEE

2 years ago

brody192


Anonymous
TRIALOP

2 years ago

ive added you


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

1234190576027697200


brody
EMPLOYEE

2 years ago

looking


brody
EMPLOYEE

2 years ago

i assume you have the root directory set to /app?


Anonymous
TRIALOP

2 years ago

yes


Anonymous
TRIALOP

2 years ago

1234191124554453200


brody
EMPLOYEE

2 years ago

where are your static files, i dont see them anywhere in the repo?


Anonymous
TRIALOP

2 years ago

I dont have any stored just the django ones that install with pip


Anonymous
TRIALOP

2 years ago

would i need to store them in the repo ?


Anonymous
TRIALOP

2 years ago

everything else is working


Anonymous
TRIALOP

2 years ago

just not the admin


Anonymous
TRIALOP

2 years ago

not a big deal but I would like it to look properly


Anonymous
TRIALOP

2 years ago

1234191616663883800


brody
EMPLOYEE

2 years ago

do you not have a static folder locally?


Anonymous
TRIALOP

2 years ago

no


Anonymous
TRIALOP

2 years ago

worked fine without it


brody
EMPLOYEE

2 years ago

send a link to your site please



brody
EMPLOYEE

2 years ago

what do you see when you visit that site?


Anonymous
TRIALOP

2 years ago

Eveything is working correctly


brody
EMPLOYEE

2 years ago

yep, looks like it was just cache



Anonymous
TRIALOP

2 years ago

looks off


Anonymous
TRIALOP

2 years ago

1234192952109170700


brody
EMPLOYEE

2 years ago

what does it look like running locally


Anonymous
TRIALOP

2 years ago

One moment not letting me run it local now


Anonymous
TRIALOP

2 years ago

1234194236296003600


brody
EMPLOYEE

2 years ago

why are you trying to access it with https?


Anonymous
TRIALOP

2 years ago

im not lol


Anonymous
TRIALOP

2 years ago

its forcing


brody
EMPLOYEE

2 years ago

what command did you run


Anonymous
TRIALOP

2 years ago

python manage.py runserver


Anonymous
TRIALOP

2 years ago

was working fine before


brody
EMPLOYEE

2 years ago

django seems to disagree with you on this


Anonymous
TRIALOP

2 years ago

1234195204894888200


Anonymous
TRIALOP

2 years ago

but it forces https


Anonymous
TRIALOP

2 years ago

1234195272666452000


brody
EMPLOYEE

2 years ago

dont open it with https


Anonymous
TRIALOP

2 years ago

1234195389280948200


brody
EMPLOYEE

2 years ago

is it redirecting you?


Anonymous
TRIALOP

2 years ago

yes


Anonymous
TRIALOP

2 years ago

it sends me to https either way i try to access it now


brody
EMPLOYEE

2 years ago

something somewhere is set to do that


Anonymous
TRIALOP

2 years ago

okay


Anonymous
TRIALOP

2 years ago

i found it


brody
EMPLOYEE

2 years ago

what was it?


Anonymous
TRIALOP

2 years ago

If i go with http://localhost:8000 it works


Anonymous
TRIALOP

2 years ago


Anonymous
TRIALOP

2 years ago

very odd


Anonymous
TRIALOP

2 years ago

1234196218058510300


Anonymous
TRIALOP

2 years ago

this is what its suppose to look like


brody
EMPLOYEE

2 years ago

what page is that


Anonymous
TRIALOP

2 years ago

django admin


brody
EMPLOYEE

2 years ago

what url path



Anonymous
TRIALOP

2 years ago


brody
EMPLOYEE

2 years ago

please go to the path you are having issues with on railway


Anonymous
TRIALOP

2 years ago

im there


Anonymous
TRIALOP

2 years ago

1234196475806880000


Anonymous
TRIALOP

2 years ago

seem the css static files are not found


brody
EMPLOYEE

2 years ago

so same thing locally then


Anonymous
TRIALOP

2 years ago

locally is showing it correctly


Anonymous
TRIALOP

2 years ago

1234196688864940000


brody
EMPLOYEE

2 years ago

please go to the same path you are having issues with on railway


Anonymous
TRIALOP

2 years ago

I am


brody
EMPLOYEE

2 years ago

/admin != /admin/login/?next=/admin/


Anonymous
TRIALOP

2 years ago

1234196926686036000


brody
EMPLOYEE

2 years ago

i can only go off the information you provide me


Anonymous
TRIALOP

2 years ago

Yes i know lol sorry


Anonymous
TRIALOP

2 years ago

I have a bigger issue. i can fix the static thing im sure by just grabbing the django files and loading adding them to the repo


Anonymous
TRIALOP

2 years ago

My threading loop wont work on the server


brody
EMPLOYEE

2 years ago

you only have 1 vcpu so theres nothing to thread


Anonymous
TRIALOP

2 years ago

that makes sence


Anonymous
TRIALOP

2 years ago

anyway to fix it ?


Anonymous
TRIALOP

2 years ago

1234197483085889800


brody
EMPLOYEE

2 years ago

upgrade to the hobby plan


Anonymous
TRIALOP

2 years ago

okay


brody
EMPLOYEE

2 years ago

i mean thats what i assume is the issue


Anonymous
TRIALOP

2 years ago

It would make the most sense if i only have one thread to work off of


aleks
HOBBY

2 years ago

Python should be smart enough to run it anyway


brody
EMPLOYEE

2 years ago

true


aleks
HOBBY

2 years ago

JS's event loop does fake threading, I'd be very surprised if Python can't do the same


brody
EMPLOYEE

2 years ago

its either bad code or trial plan


Anonymous
TRIALOP

2 years ago

yeah I wasn't sure if it was the best way to go but this is just proof of concept right now getting everything working


Anonymous
TRIALOP

2 years ago

I was going to use celery but that was a can of worms i couldn't figure out without deep dive


Anonymous
TRIALOP

2 years ago

2 vCPU per Container


Anonymous
TRIALOP

2 years ago

the trial has 2 soo it should work if that was the issue


brody
EMPLOYEE

2 years ago

where does it say that, i thought it was 1


Anonymous
TRIALOP

2 years ago

1234198844128886800


Anonymous
TRIALOP

2 years ago

im planning on upgrading once i get it working


Anonymous
TRIALOP

2 years ago

but I'm not sure how railway handles threading


brody
EMPLOYEE

2 years ago

well then that leaves code issue


brody
EMPLOYEE

2 years ago

nothing to do with railway


Anonymous
TRIALOP

2 years ago

Okay. So if it works locally without issues where would i start looking if its on railway


Anonymous
TRIALOP

2 years ago

my logs give me nothing


brody
EMPLOYEE

2 years ago

i honestly wouldnt know, but if your logs give you nothing then you are not logging anything, id start by adding verbose logging


Anonymous
TRIALOP

2 years ago

that would be good how can i add the verbose logging to my start up with gunicorn


brody
EMPLOYEE

2 years ago

find a logging package you like and start using it


Anonymous
TRIALOP

2 years ago

I can just use regular python logging packages? nothing special for railway?


brody
EMPLOYEE

2 years ago

of course, what makes you think youd need to use something special?


Anonymous
TRIALOP

2 years ago

Idk still relatively new to web server stuff wasn't sure if there was anything special about it


brody
EMPLOYEE

2 years ago

when it comes down to it, its just printing text, nothing platform specific in any way


Anonymous
TRIALOP

2 years ago

I appreciate all your help I'm gonna do some bug testing and some deeper logging.


Anonymous
TRIALOP

2 years ago

Thank you


brody
EMPLOYEE

2 years ago

no problem!


Loading...