djangodockerdocker-compose

Got an error while running a django project in docker


This site can’t be reached The webpage at http://0.0.0.0:8000/ might be temporarily down or it may have moved permanently to a new web address. ERR_ADDRESS_INVALID

I want the correct starting page of first page of project.I tried multiple times, but the error is same.


Solution

  • You should access the application (on the machine not the container) using localhost:8000 or 127.0.0.1:8000.

    When running your Docker container, specify the port mapping as follows:

    docker run -p 8000:8000 image_name
    

    And when launching Django, use the following command to ensure it binds to the correct IP and port:

    python manage.py runserver 0.0.0.0:8000
    

    Note: It's important to bind the Django server to 0.0.0.0 inside the Docker container so it's accessible from the host machine.