Docker Container running but can't access it on my browser

Hey everyone, I am pretty new to Docker and I have this issue that I have been dealing with for days. My containers are running fine, but then I can’t access my app from the browser. I get the response.

This page isn’t working

0.0.0.0 didn’t send any data.

ERR_EMPTY_RESPONSE

I have google serached this specific error and below is what I have tried:

I have reset the database, and also done a recent migration.

Some internet articles suggested checking the internet connection, I did that and also reset my network connection. I also tried tethering off of my phone, just to be sure.

I have cleared my cache, cookie and browsing history. I have tried using a different browser too. I also disabled my browser extensions. I have tried to open the server in an incognito browser.

I tried to change the port and also add a health check for the database to make sure it’s healthy before the django app starts. I also added a wait for the database script to ensure the app doesn’t try to connect to the database before it is ready.

I tried to run it on a windows laptop, and everything worked just fine. Also, my firewall is off on my mac and I am using macOS Ventura 13.5.2.

I also tried to enter the container using curl and I am getting

(52) Empty reply from server

Here is my docker compose file

volumes:
  rhs_soccer_local_postgres_data: {}
  rhs_soccer_local_postgres_data_backups: {}
  rhs_soccer_local_redis_data: {}

services:
  django: &django
    build:
      context: .
      dockerfile: ./compose/local/django/Dockerfile
    image: rhs_soccer_local_django
    container_name: rhs_soccer_local_django
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started
      mailpit:
        condition: service_started
    volumes:
      - .:/app:z
    env_file:
      - ./.envs/.local/.django
      - ./.envs/.local/.postgres
    ports:
      - '8000:8000'
    command: /start
    # restart: unless-stopped 


  postgres:
    build:
      context: .
      dockerfile: ./compose/production/postgres/Dockerfile
    image: rhs_soccer_production_postgres
    container_name: rhs_soccer_local_postgres
    volumes:
      - rhs_soccer_local_postgres_data:/var/lib/postgresql/data
      - rhs_soccer_local_postgres_data_backups:/backups
    env_file:
      - ./.envs/.local/.postgres
    healthcheck:
      test: ["CMD-SHELL", pg_isready -h postgres -p 5432]
      interval: 10s
      timeout: 10s
      retries: 5
      start_period: 60s
    # ports:
    #   - "5432:5432"

  mailpit:
    image: docker.io/axllent/mailpit:latest
    container_name: rhs_soccer_local_mailpit
    ports:
      - "8025:8025"

  redis:
    image: docker.io/redis:6
    container_name: rhs_soccer_local_redis
    
    volumes:
      - rhs_soccer_local_redis_data:/data
    

  celeryworker:
    <<: *django
    image: rhs_soccer_local_celeryworker
    container_name: rhs_soccer_local_celeryworker
    depends_on:
      - postgres
      - redis
      - mailpit
    env_file:
      - ./.envs/.local/.django
      - ./.envs/.local/.postgres
    ports: []
    command: /start-celeryworker

  celerybeat:
    <<: *django
    image: rhs_soccer_local_celerybeat
    container_name: rhs_soccer_local_celerybeat
    depends_on:
      - postgres
      - redis
      - mailpit
    env_file:
      - ./.envs/.local/.django
      - ./.envs/.local/.postgres
    ports: []
    command: /start-celerybeat

  flower:
    <<: *django
    image: rhs_soccer_local_flower
    container_name: rhs_soccer_local_flower
    ports:
      - '5555:5555'
    command: /start-flower

Any help will be highly appreciated and also, if more information is needed I am more than happy to provide that.


Please, format your post according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.

Example code block:

```
services:
  service1:
    image: image1
```

After fixing your post, please send a new comment so people are notified about the fixed content.


The formatting is fixed, hopefully it’s better presented now?

I hope you didn’t use this invalid IP address to access the port. Even if it works on Windows and somehow finds an IP, you should use a valid, specicif IP address. It could be 127.0.0.1 or just simply localhost instead of an IP.

If you saw in a log that the application was listening on this “IP”, it just meant it was listening on all available IP addresses in the container. But that doesn’t matter because you are accessing to the container from the host, so you need a host IP. Ports are also forwarded from all IP addresses by default, so you can sue any valid IP address on your mac.