Setting up Home Assistant in Docker for Windows with Port Forwarding Enabled

I hope that you’ve landed here before spending hours/days trying to find a solution as to why you can’t forward the Home Assistant port in Docker. The solution is frustratingly easy.


The install Home Assistant in docker on Windows instructions are great, with one exception. It explains the required prerequisites to make sure docker has access to a host disk. However, those instructions have outdated instructions to setup the port-forward rules, which ultimately makes it a waste of time.

They share this command (don’t use):

docker run --init -d --name="home-assistant" -e "TZ=America/Los_Angeles" -v //c/Users/[USER]/homeassistant:/config --net=host homeassistant/home-assistant:stable

It installs fine and spins up the container. The docs say to next use netsh and manually add port-forward rules, but it doesn’t work (and you can seriously mess stuff up with netsh).


Instead, you can just tell docker to port forward it for you when you initially create the container by using the -p switch. Since Home Assistant uses port 8123, you use -p 8123:8123 in the command.

Here’s the one-liner that does both the install, and the port forward, at the same time:

docker run -p 8123:8123 --name="home-assistant" -e "TZ=America/Los_Angeles" -v //c/Users/lance/homeassistant:/config homeassistant/home-assistant:stable

After that, you’re ready to go! Open a browser on the host PC and navigate to http://localhost:8123.

Important -p 8123:8123 parameter must be used before --name. Otherwise, it gets used in the container instead of Docker, which results in a broken install because the container doesn’t know what -p is. I wasted two days before discovering this, thanks to help from Alex Sorokoletov and Martin Sundhaug. I owe them some 🍻.

4 thoughts on “Setting up Home Assistant in Docker for Windows with Port Forwarding Enabled

  1. Belknap says:

    Did you figure out a way to forward other ports so that host’s network, and other other functionality – including mDNS and UPnP are not broken?

    1. Lance says:

      I’m using a PiHole for DNS and Caddy for reverse proxy, but other port-specific things seem to work because the VM has its own IP address. Caddy forwards all traffic to HA via via external (I am using the LetsEncrypt Add-On for SSL and the port assignments seem to work as expected).

    2. Pedro Lamas says:

      mDNS and UPnP will only work if attached to host network (–net=host) or if you use a mDNS reflector such as Avahi (
      If you ask me, option 1 is still preferable (I see no reason to have HA on a bridge instead of the host network), but if you go with option 2, be aware that you will then need to attach the Avahi container to both the host network and the bridge networks that you wish to have mDNS.

      1. Lance says:

        Agreed, this was a limiting factor for me. I ended up switching to Hyper-V, which gets its own virtual adapter attached to the host’s network. Bonjour/avahi works perfectly there.


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.