Cannot access localhost:8123 when running in docker with network=host

Hi there. I want to run Home Assistant on my M1 Mac mini with Docker. I have it working fine when I run the container in network mode bridge and exposing port 8123, but with that configuration I was not able to use the HomeKit integration (I also tried to expose the default port for the HomeKit integration, 21603).

After looking around topics in the community it seems like I have to run the Home Assistant container in network mode host for the HomeKit integration to work properly. When I do this I get no error logs and the container looks healthy, but I cannot find the Home Assistant UI anywhere (localhost:8123 or IP:8123). I also cannot find the port using sudo lsof -i -n -P | grep 8123.

Thanks for any help!

Should be

homeassistant:8123

or

YourMacIP:8123
eg. 192.168.1.1:8123
```

Neither of these are available. If I ping them I get ping: cannot resolve (MacIP):8123: Unknown host

the actual IP address of your mac mini
Don’t think you can ping a IP:port (you can’t in windows anyway)

http://localhost:8123, http://homeassistant.local:8123 or http://(MyMacIP):8123 all gives refused to connect in my browser.

Does that work from console?

docker exec -it homeassistant /bin/bash

can you detail your install and setup abit further? You are on the macMini or ssh?
macOS or linux?
which install method did you use (docker you said) so linux os? or is there a docker image for macOS?
So plain container no supervisor?

I am on the M1 Mac mini running macOS Monterey 12.6 and use the homeassistant/home-assistant:latest image. I run the following command to start Home Assistant:

docker run -d \                                                                 
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ="Europe/London" \
  -v homeassistant_data:/config \
  -p 8123:8123 \
  --network=host \
  homeassistant/home-assistant:latest

Home Assistant works flawlessly and is available at localhost:8123 when I run it with:

docker run -d \                                                                 
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ="Europe/London" \
  -v homeassistant_data:/config \
  -p 8123:8123 \
  --network=bridge \
  homeassistant/home-assistant:latest

Linux Docker container install docs

Hmm looks the same except for the image. Although latest and stable appear to be the same image atm. Not sure why macOS doesn’t have container instructions.

what does ifconfig show for eth0: ?? That should be the address to use.

docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=MY_TIME_ZONE \
  -v /PATH_TO_YOUR_CONFIG:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

You could ask here too.
HA discord Install channel

I believe the host option is not working as expected on Macs.

This is stated on the ESPHome docs for running ESPHome as a docker container:

# On Docker, host networking mode is required for online status indicators
docker run --rm --net=host -v "${PWD}":/config -it esphome/esphome

# On Docker with MacOS, the host networking option doesn't work as expected. An
# alternative is to use the following command if you are a MacOS user.
docker run --rm -p 6052:6052 -e ESPHOME_DASHBOARD_USE_PING=true -v "${PWD}":/config -it esphome/esphome

Similar case: Unable to access after docker initialization in osx

1 Like