HomeAssistant running on Docker Desktop for Windows but not accessible from browser

Hello,

I’m a software developer but new to HomeAssistant. I have HomeAssistant running, or at least appears to be running, via a docker container but I cannot connect to it from my host machine, the WSL VM, or even exec’ed into the container that is running itself.

My setup:

OS Name:         Microsoft Windows 10 Home
OS Version:      10.0.19043 N/A Build 19043
Docker version 20.10.11, build dea9396

I started the container using this command:

docker run -d -p 8123:8123 --privileged \
  --volume "C:\Program Files\homeassistant:/config" \
  --name homeassistant \
  --network host \
  -e "TZ=America/New_York" ghcr.io/home-assistant/home-assistant:stable

The container stays running and has this in the logs:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.

Yet none of these load from my browser:

  • http://localhost:8123
  • http://127.0.0.1:8123
  • http://host.docker.internal:8123

And even when I hop into the WSL VM that I’ve configured docker to use (wsl -d Ubuntu), I just get:

$ curl localhost:8123
curl: (7) Failed to connect to localhost port 8123: Connection refused
$ curl http://127.0.0.1:8123
curl: (7) Failed to connect to 127.0.0.1 port 8123: Connection refused

And even when I exec into the container via docker exec -ti homeassistant /bin/bash:

# curl -v http://127.0.0.1:8123
*   Trying 127.0.0.1:8123...
* Connected to 127.0.0.1 (127.0.0.1) port 8123 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8123
> User-Agent: curl/7.78.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< location: /onboarding.html
< Content-Length: 0
< Content-Type: application/octet-stream
< Date: Fri, 24 Dec 2021 11:43:38 GMT
< Server: Python/3.9 aiohttp/3.8.1
<
* Connection #0 to host 127.0.0.1 left intact

Which I guess actually looks like it’s connecting to the server, but no data is being returned.

It’s doing a redirect, so use “curl -L” to follow through.
You’re likely have networking issues between Windows proper and WSL(2?).

@koying

It’s doing a redirect, so use “curl -L” to follow through.

Yes, you’re right, doing curl -L http://127.0.0.1:8123 while exec’ed into the docker container gives me an HTML page. So I know the server is running and serving the page, there seems to be some kind of a networking block.

You’re likely have networking issues between Windows proper and WSL(2?).

Yes, it’s WSL 2.

Maybe there are also networking issues between Windows proper and the WSL2 VM, but even ignoring windows, when I hop into the Ubuntu terminal I can see:

$ docker ps -a
CONTAINER ID   IMAGE                                          COMMAND   CREATED       STATUS       PORTS     NAMES
e2266fce648b   ghcr.io/home-assistant/home-assistant:stable   "/init"   3 hours ago   Up 3 hours             homeassistant

But no web page:

$ curl -L -v http://127.0.0.1:8123
*   Trying 127.0.0.1:8123...
* TCP_NODELAY set
* connect to 127.0.0.1 port 8123 failed: Connection refused
* Failed to connect to 127.0.0.1 port 8123: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 127.0.0.1 port 8123: Connection refused

Turns out it was the --network=host option:

From here:

The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.

So removing that flag and using this command:

docker run -d -p 8123:8123 --privileged --volume "C:\Program Files\homeassistant:/config" --name homeassistant -e "TZ=America/New_York" ghcr.io/home-assistant/home-assistant:stable

And now I can access my home assistant :slight_smile:

2 Likes