Django apps not responding anymore...
Hello all! I realized after the latest updates on railway (I don't know if it's related) but I noticed when I deploy my django apps, I see an error Application failed to respond
but nothing on my logs. This is the third time I have this issue and when I deploy the same app in a regular VPS on Digitalocean it turns out fine. What's going on?
52 Replies
Project ID:
fa6ecf07-3925-4229-9a3a-2ba5b2bc79d4
fa6ecf07-3925-4229-9a3a-2ba5b2bc79d4
Hello?
Could you perhaps post some logs from the build/deployment process? I know you said nothing on your logs, but I assume you were talking about the logs from the app.
I only see this:
[2023-07-31 00:08:10 +0000] [1] [INFO] Starting gunicorn 21.2.0
[2023-07-31 00:08:10 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2023-07-31 00:08:10 +0000] [1] [INFO] Using worker: sync
[2023-07-31 00:08:10 +0000] [7] [INFO] Booting worker with pid: 7
[2023-07-31 00:08:10 +0000] [8] [INFO] Booting worker with pid: 8
[2023-07-31 00:08:10 +0000] [9] [INFO] Booting worker with pid: 9
[2023-07-31 00:08:10 +0000] [10] [INFO] Booting worker with pid: 10
Can you show me your start command please?
Here is my entire Dockerfile:
FROM python:3.10.8-slim-buster
WORKDIR /usr/src/app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN pip install --upgrade pip
COPY ./requirements.txt /usr/src/app
RUN pip install -r requirements.txt
COPY . /usr/src/app
RUN python manage.py update_database_settings
RUN python manage.py makemigrations
RUN python manage.py migrate
RUN DJANGO_SUPERUSER_USERNAME=kaiss \
DJANGO_SUPERUSER_PASSWORD=xxxxxxxx \
[email protected] \
python manage.py createsuperuser --noinput || true
EXPOSE 8000
CMD ["gunicorn", "nafssi.wsgi:application", "-w", "4", "-b", "0.0.0.0:8000"]
Since you are listening on port 8000, in your service on the railway dashboard, set an environment variable of
PORT
and set it to 8000
That should solve it for youBecause the railway container injects a port variable for you that’s random, it won’t always line up with what you expose from your app
use this please
what database type are you using? postgres?
yes
one sec
okay you are set, please use that dockerfile
If you use Brody’s dockerfile, don’t set the environment variable in your service
always use my dockerfiles 🙂
Hush! 🤣🤣
hooold on now hahaha; I set the PORT var, I'll try if it works, if it doesn't I'll use Brody's one 😄
please use mine anyway
hahah, ok now I have ERR_TOO_MANY_REDIRECTS
I have the exact same Dockerfile deployed on DO and with no problems
please use my dockerfile, you should not be running createsuperuser from the dockerfile
Yeah, this is a bad idea
I was just about to ask why did you remove the createsuperuser, I just did it because I created a new DB on railway and I wanted to directly start using the app for testing purposes only
Every time you deploy, it will run that code
yes but it will do it only if the user does not exist
You would want to use the CLI, and link the service and run the command that way
but anyways, I removed it, now I'm waiting for the autodeployment
And if it fails to create the user, the deploy will fail, normally
are you using cloudflare
yes, and I have 2 environments on railway: production (nafssi.ma) and development (dev.nafssi.ma)
I added the 2 CNAMEs with and without proxy, both of them don't work
which is weird because I launched a little AI product called debuggr.net last year and it's on railway and built with django and it works just fine
you can try it it's fun 😄
The difference between debuggr.net and nafssi.ma is that with debuggr, I use the CNAME to point to the generated railway.app link I have, but with nafssi.ma, I used the CNAME value that railway.app provided me when I added the custom domain.
Are your SSL settings set to Full?
I just set them to Full now as per the railway doc
but in the debuggr.net project it's set to flexible and it works
ok I think I made some progress, I ditched the domain names railway provided me with and I replaced the records by the generated railway domains, set them to proxy, and set the SSL mode to full
now it gives me a 500 Error
so I'm getting close
Are you using your dockerfile still or Brody’s?
no Bordy's
Okay. Cool. Do you still have the PORT environment variable set?
the thing is, I have set DEBUG to True, I have Error 500, and nothing on the logs
no I removed the PORT var
Hmmm
Shouldn’t be giving trouble at this point… are you able to share the repo? I could look at it in about an hour or so when I get back on my computer
give me ur email
GitHub username is vfehring
done
Cool. I’ll look at it in a bit, and see if we can resolve this for you
Thank you so much! I think if we find the solution, it's gonna be the same for the other projects I have the same issue with (2 other django apps with the exact same issue...)
are you guys django developers as well?
I am
Well, Django and flask
Great, I'm a Fractional CTO and I am a Django, Flask and FastAPI dev 😄
It's nice to meet you!
Nice! I love Python. I do a lot more than just Python, but it’s one of my favorites
Me too! I went from Java to Python in 2014
Never went back 😄
Where are you from Vin?
Houston
Great
I'm from Morocco
Casablanca to be exact
Very nice. I have a friend over there
Very good!
And I have a friend in Houston too 😄 an old college roomate who works in AWS now
any luck?
Haven’t had a chance to look at it. Moved my computer and had a full system meltdown. Will be looking at it tonight for sure
Looking into this now for you