Homekit App Timing Out on QR Code Scan

I have Docker running on macOS and get a time out in the home app when I scan the QR code given by home assistant. I read a number of threads on the subject without success. This is where I am now based on what I’ve found.

configuration.yaml:

homekit:
  port: 51827
  filter:
   include_entities:
      - demo.demo

docker-compose file

version: '3.0'
services:
   homeassistant:
        container_name: home-assistant-compose
        hostname: home_assistant
        image: homeassistant/home-assistant:stable
        volumes:
           - /Users/curt/.config/home-assistant:/config
        network_mode: host
        ports:
          - "8123:8123"
          - "51827:51827"
        restart: always

I don’t know that the ports are necessary with network_mode set to host. IIRC removing them or al least 8123 stopped home assistant from working at all. The Dockerfile is empty so I’m not sure what OS in being run.

I’ve see mention of avahi. Is this something I have to install to get this to work?

Update

Someone mentioned changing the port to get it work. I tried changing it to 51829 in all references to no avail.
Homekit is connected to home bridge running on the same Mac as Home Assistant although directly on the OS. Homekit is also comment to my Lutron Caseta bridge.
When rebooting Home Assistant, I usually get two QR images with eh same timestamp.
Changed device to demo.demo.
Changed docker-compose file version to 3.4 from 3.0
From another post on this problem, I tried:

dns-sd -R Homeassistant _hap._tcp local 51827 md=”HA Bridge” pv=1.0 c#=2 id=00:11:22:33:44:55 s#=1 sf=1 ci=2 ff=0 sh=UaTxqQ== 

The post mentions matching using the in the .homekit.state file. I had two of them. I deleted and rebooted and then used the MAC from the newly created file. Again, no luck

I confirmed that removing the ports from the docker compose file stops the web browser from reconnecting even though the docker image runs. It’s as if the network_mode: host isn’t being recognized .
Now network:host has stopped working. I can’t connect via the browser. I fell back to my command line invocation:

docker run --init -d --name="home-assistant" --network="host" -e "TZ=America/Los_Angeles" -v ~/.config/home-assistant:/config -p 8123:8123 -p 51829:51829 homeassistant/home-assistant:stable

It doesn’t work if I drop the network option and run:

docker run --init -d --name="home-assistant" -e "TZ=America/Los_Angeles" -v ~/.config/home-assistant:/config -p 8123:8123 -p 51829:51829 homeassistant/home-assistant:stable

it runs again. Notice, I’m also trying a different port. I’m running homebridge on the same Mac. On the chance it’s using 51827, I changed it. It still doesn’t work. I checked on homebridge. Its running on 51826

I changed the composer version back to 3.0. Network_mode: host now works again