Unable to deploy Django app

Hi,
I have an app running on Django app which is running perfectly locally. When I deploy, everything goes well, but the final step of deployment fails after being stuck for 4-5 mins.

1 desired, 1 placed, 0 healthy, 1 unhealthy [health checks: 1 total, 1 critical]
v2 failed - Failed due to unhealthy allocations - no stable job version to auto revert to
Failed Instances

In Logs too, do not get an issues:

2021-11-13T10:08:37.888 app[f2586374] maa [info] Starting init (commit: 7943db6)…
2021-11-13T10:08:37.905 app[f2586374] maa [info] Preparing to run: python manage.py runserver as root
2021-11-13T10:08:37.920 app[f2586374] maa [info] 2021/11/13 10:08:37 listening on [fdaa:0:2fc7:a7b:14bf:f258:6374:2]:22 (DNS: [fdaa::3]:53)
2021-11-13T10:08:38.650 app[f2586374] maa [info] Watching for file changes with StatReloader
2021-11-13T10:08:38.650 app[f2586374] maa [info] Performing system checks…
2021-11-13T10:08:38.797 app[f2586374] maa [info] System check identified some issues:
2021-11-13T10:08:38.797 app[f2586374] maa [info] WARNINGS:
2021-11-13T10:08:38.797 app[f2586374] maa [info] ?: (2_0.W001) Your URL pattern ‘^download/(?P.*)$’ has a route that contains ‘(?P<’, begins with a ‘^’, or ends with a ‘$’. This was likely an oversight when migrating to django.urls.path().
2021-11-13T10:08:38.797 app[f2586374] maa [info] System check identified 1 issue (0 silenced).
2021-11-13T10:08:38.883 app[f2586374] maa [info] November 13, 2021 - 10:08:38
2021-11-13T10:08:38.883 app[f2586374] maa [info] Django version 3.1.7, using settings ‘MCMCR_Website.settings’
2021-11-13T10:08:38.883 app[f2586374] maa [info] Starting development server at http://127.0.0.1:8000/

Can you tell me what I may be doing wrong?

Here’s the content of Fly.toml

fly.toml file generated for mcgm on 2021-11-13T14:08:57+05:30

app = “mcgm”

kill_signal = “SIGINT”
kill_timeout = 5

[[services]]
internal_port = 8000
protocol = “tcp”

[services.concurrency]
hard_limit = 25
soft_limit = 20
type = “connections”

[[services.ports]]
handlers = [“http”]
port = 80

[[services.ports]]
handlers = [“tls”, “http”]
port = 443

[[services.tcp_checks]]
grace_period = “30s”
interval = “15s”
restart_limit = 0
timeout = “2s”

And here is my Docker file

FROM python:3.9

ENV PYTHONUNBUFFERED=1

WORKDIR /usr/src/app

COPY requirements.txt /usr/src/app/

RUN pip install -r requirements.txt

COPY . /usr/src/app/

CMD [“python”,“manage.py”,“runserver”]

Checking if a health check is failing for any reason is a good place to start, fly checks list should indicate that.

The logs also seem to be indicating that a development server is starting? Many frameworks will restrict development mode to only take connections on localhost or refuse to serve requests from other machines — for a production server I would have expected it to bind on 0.0.0.0:8000 or better still [::]:8000. Binding on 127.0.0.1:8000 means only requests from that machine itself will be accepted.

Hi Sudhir,
I had allowed all hosts in settings. However, I had to bind 0.0.0.0 when starting the server. Once I did that, it started working.

Thanks for your help.

Amit Pareek