network=host does not work on Home Assistant

Home Assistant is a great tool if you want to automate your home.

However, there are slight issues with it. Based on official installation instructions, we see that we should run the Docker container or our Raspberry Pi as follows:

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

# In my case:
docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Europe/Vilnius \
  -v /home/ernestas/homeassistant:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

Note the –network=host part. In theory, it should force Docker container to use ports from the host – i.e. my Raspberry Pi – machine. However, when I start my Docker container with this configuration, I can not reach installed Home Assistant via http://<my_ip>:8123/

After some googling, I found that there are similar complaints on the Internet:

Long story short, –network=host does not work. What to do? Expose ports directly, like this:

# 8123 is a UI port
# 5353 is a mDNS (service self - discovery port)
docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Europe/Vilnius \
  -v /home/ernestas/homeassistant:/config \
  -p 8123:8123 \
  -p 5353:5353 \
  -p 1900:1900 \
  -p 5683:5683 \
  -p 51827:51827 \
  -p 3000:3000 \
  -p 3001:3001 \
  ghcr.io/home-assistant/home-assistant:stable

After these changes, I can run my Home Assistant.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *