[Fixed]-"The connection was reset" in localhost:8000 using django and docker

24👍

Your application only listens to requests coming from localhost, which in case of a container are requests coming from inside the container.

Try this compose file:

version: '3'

services:
    web:
        build: .
        container_name: docker_django
        command: python manage.py runserver 0.0.0.0:8000
        volumes:
            - .:/code
        ports:
            - "8000:8000"

corrected typo for port number as suggested

👤Mihai

-1👍

What ended up working for me was:

  1. Stopping all docker instance
  2. Opening a command prompt in admin mode
  3. Executing the command ‘netsh winsock reset’
  4. Restarting the machine
  5. Restarting docker containers

Leave a comment