502 Bad Gateway connection refused error

Hello,

I have exactly the same bug.

For the Home Assistant you need to discover why traefik is resolving the container to 127.0.0.1

How did you solve your HA problem @ben9519? I don't understand why 127.0.0.1 is the problem. All containers in docker-compose.yml use host network_mode. In the host, I can access HA using http://127.0.0.1:8123 without problem.

For reference:

version: '3'
services:
  traefik:
    image: traefik:v2.3
    container_name: traefik
    restart: unless-stopped
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
      - "--certificatesresolvers.myresolver.acme.email=myemail@example.com"
      - "--certificatesresolvers.myresolver.acme.storage=/traefik/letsencrypt/acme.json"
    ports:
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./traefik:/traefik
  homeassistant:
    container_name: home-assistant
    image: homeassistant/home-assistant:stable
    volumes:
      - ./hass:/config
    restart: unless-stopped
    network_mode: host
    ports:
      - "8123:8123" # This is required as well.
    expose:
      - 8123 # As is this.
    labels:
      - traefik.enable=true
      - traefik.http.routers.homeassistant.rule=Host(`hass.my.example.com`)
      - traefik.http.routers.homeassistant.entrypoints=websecure
      - traefik.http.routers.homeassistant.tls=true
      - traefik.http.routers.homeassistant.tls.certresolver=myresolver
      - traefik.http.services.homeassistant.loadbalancer.server.port=8123