#Django apps not responding anymore...

77 messages · Page 1 of 1 (latest)

rigid bane
#

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?

analog sirenBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

wary iglooBOT
#

Project ID: fa6ecf07-3925-4229-9a3a-2ba5b2bc79d4

rigid bane
#

fa6ecf07-3925-4229-9a3a-2ba5b2bc79d4

rigid bane
#

Hello?

uneven hedge
#

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.

rigid bane
#

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

frosty wyvern
rigid bane
#

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"]

frosty wyvern
#

That should solve it for you

fickle rock
#
FROM python:3.10.8-slim-buster

ARG PGHOST PGPORT PGUSER PGPASSWORD PGDATABASE DATABASE_URL

WORKDIR /usr/src/app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

COPY requirements.txt ./
RUN pip install -r requirements.txt

COPY . ./

RUN python manage.py update_database_settings
RUN python manage.py makemigrations
RUN python manage.py migrate

CMD ["gunicorn", "nafssi.wsgi:application", "-w", "4"]
frosty wyvern
#

Because 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

fickle rock
#

use this please

#

what database type are you using? postgres?

rigid bane
#

yes

fickle rock
#

one sec

#

okay you are set, please use that dockerfile

frosty wyvern
#

If you use Brody’s dockerfile, don’t set the environment variable in your service

fickle rock
#

always use my dockerfiles 🙂

frosty wyvern
rigid bane
#

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 😄

fickle rock
#

please use mine anyway

rigid bane
#

hahah, ok now I have ERR_TOO_MANY_REDIRECTS

rigid bane
#

I have the exact same Dockerfile deployed on DO and with no problems

fickle rock
#

please use my dockerfile, you should not be running createsuperuser from the dockerfile

rigid bane
#

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

frosty wyvern
#

Every time you deploy, it will run that code

rigid bane
#

yes but it will do it only if the user does not exist

frosty wyvern
#

You would want to use the CLI, and link the service and run the command that way

rigid bane
#

but anyways, I removed it, now I'm waiting for the autodeployment

frosty wyvern
#

And if it fails to create the user, the deploy will fail, normally

fickle rock
#

are you using cloudflare

rigid bane
#

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.

frosty wyvern
#

Are your SSL settings set to Full?

rigid bane
#

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

frosty wyvern
#

Are you using your dockerfile still or Brody’s?

rigid bane
#

no Bordy's

frosty wyvern
#

Okay. Cool. Do you still have the PORT environment variable set?

rigid bane
#

the thing is, I have set DEBUG to True, I have Error 500, and nothing on the logs

#

no I removed the PORT var

frosty wyvern
#

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

rigid bane
#

give me ur email

frosty wyvern
#

GitHub username is vfehring

rigid bane
#

done

frosty wyvern
#

Cool. I’ll look at it in a bit, and see if we can resolve this for you

rigid bane
#

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?

frosty wyvern
#

I am

#

Well, Django and flask

rigid bane
#

Great, I'm a Fractional CTO and I am a Django, Flask and FastAPI dev 😄

#

It's nice to meet you!

frosty wyvern
#

Nice! I love Python. I do a lot more than just Python, but it’s one of my favorites

rigid bane
#

Me too! I went from Java to Python in 2014

#

Never went back 😄

#

Where are you from Vin?

frosty wyvern
#

Houston

rigid bane
#

Great

#

I'm from Morocco

#

Casablanca to be exact

frosty wyvern
#

Very nice. I have a friend over there

rigid bane
#

Very good!

#

And I have a friend in Houston too 😄 an old college roomate who works in AWS now

rigid bane
#

any luck?

frosty wyvern
#

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