Fully functional Django app giving a warning on deploy

WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.
You can fix this by configuring your app to listen on the following addresses:
- 0.0.0.0:8000

I’ve got this app set up just like another apps I have running on Fly that don’t have that warning. I’ve been pouring over this forum, but I haven’t found anything to help me fix this yet. I even tried destroying and re-launching the app. Same warning.

Relevant(?) parts of fly.toml:

[env]
  PORT = "8000"

[[mounts]]
  source = "storage"
  destination = "/mnt/storage"

[http_service]
  internal_port = 8000
  force_https = true
  auto_stop_machines = false
  auto_start_machines = true
  min_machines_running = 0

[[statics]]
  guest_path = "/code/static"
  url_prefix = "/static/"

and Dockerfile:

FROM python:3.11.3

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN mkdir -p /code

WORKDIR /code

# install Git and Node
RUN apt-get update && \
    apt-get install -y git && \
    apt-get remove nodejs npm && \
    apt-get install -y curl && \
    curl -fsSL https://deb.nodesource.com/setup_18.x | bash && \
    apt-get install -y nodejs

COPY requirements/requirements.txt /tmp/requirements.txt

RUN set -ex && \
    pip install --upgrade pip && \
    pip install -r /tmp/requirements.txt && \
    rm -rf /root/.cache/

COPY . /code/

EXPOSE 8000

CMD ["/bin/bash", "-c", "npm i; npm run build; python manage.py collectstatic --noinput; python manage.py migrate --noinput; gunicorn --bind :8000 --workers 2 config.wsgi"]

You could try changing this to gunicorn --bind [::] :8000 or gunicorn --bind 0.0.0.0:8000

If the warning still continues but your app works fine then possibly there is a bug in the code that generates the warning.

Good ideas, but neither worked. :upside_down_face: Really odd that there would be a bug that only effects one app of my several running on Fly, but I’m not ruling it out!

I’m guessing it’s some sort of race condition. I moved the npm i and npm build outside of the Docker CMD and I’m no longer getting the warning.

# …

EXPOSE 8000

RUN npm i && npm run build

CMD [ (same stuff minus that npm stuff) ]

I guess the Fly monitoring wasn’t picking up that it was listening to that port yet since it was still running build stuff?

Anyway, let me know if I’m way off here, but I’m happy for now!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.