Docker not activating ports

I’m trying to install hass.io in a docker container, but I get no network or ports. And I have no idea what I’m doing wrong. I’m using docker-compose with these settings:

version: '3'
services:
  homeassistant:
    container_name: home-assistant
    image: homeassistant/home-assistant
    volumes:
      - ~/config/ha:/config
      - /etc/localtime:/etc/localtime:ro
    restart: always
    network_mode: host

But when I start it either with rebooting or docker-compose up -d it will start without assigning any network. What am I doing wrong?

As you can see in the picture Portainer works as expected.

Things I have tried:

  • Install with standard HA config
  • Delete image and fresh install

my view is exactly the same.
I think potentially you have no ports showing because you’re not mapping ports, but most importantly I think it’s because network_mode: host is defined.
Again my portainer view is 100% the same so don’t think there’s an issue with Docker.
Are you having issues other than this?

1 Like

Seems what you said was the case. I changed my file to this, and now it seems to work:

version: '3'
services:
  homeassistant:
    container_name: home-assistant
    image: homeassistant/home-assistant
    ports:
      - "8123:8123"
    volumes:
      - /home/user/config/home-assistant:/config
      - /etc/localtime:/etc/localtime:ro
    restart: always
    # network_mode: host

Thanks for the help!

3 Likes

Not to rehash a solved thread but from your last post I think you may have missed the point.

There were no ports listed because it didn’t need to list any ports because all of the ports on the host were exposed by setting network mode to host. That means that any port that is accessed on the host can also be accessed by the container. So if you can reach 8123 on the host you can also reach the container thru 8123. There is no need to put in the “ports:” section if you have “network_mode: host” set. right now you only have one port on the host exposed to HA (8123).

1 Like

I’m having this problem right now. It seems that port 8123 will not resolve to my Home Assistant (Hassio) install on Docker. It works for about a day and then I can’t reach the Hassio frontend anymore. I can see that everything is running and there are no errors in the logs. Do you know why 8123 would suddenly stop resolving to Hassio?

No sorry I have no idea how to troubleshoot hassio issues. I’ve never used it.

Well I don’t know that it’s so much a hassio issue as an issue with docker and the host ubuntu machine not allowing port 8123. I don’t have a firewall enabled on the host so I’m not sure why the port would be closed.

I’m not sure why it would be a docker/host/firewall issue either. I would think that the port would either consistently work or not based on any configuration that you have in the container. Since it works intermittently I would tend toward thinking it’s a hardware or network issue.

did you ever solve this. I think I’m running into the same thing.

Instead of blaming the docker instance, or the network, have you thought it might not be starting because of a corrupt DB file or a bad config yaml?

Look at the home assistant log and see if it’s even running. The container running doesn’t mean home assistant is running.

I’ve done config checks right before restarting and losing access, and all checks out fine. I had a uptime of 7 days with no changes and restarted and lost access. makes no sense to me.

Config check doesn’t mean much.

And like I said, it could be a corrupt DB file. Read the logs and it will tell you what’s wrong

yea logs don’t show any errors. restarting from scratch again now.

Or try deleting the DB file and restarting?

yea I tried that as well with now luck. Just rebuilt from scratch and after adding integrations only and restarting I can’t access again.

Why did you restart after adding integrations? What did you modify in the yaml?

Do you have a Chromecast? That turned out to be the root of my issues. For some reason (I still don’t know why) everytime I would configure the Chromecast it would cause port 8123 to become inaccessible. Once I removed the Chromecast, everything has been fine since. If you are running hassio and you let hassio configure it for you, you can go to /config/.storage/core.config_entries (something like that) and remove the portion that looks like this: https://imgur.com/a/jSt3a6I. Hope this helps!

hmm I do have google homes that use the cast component, but I’ve never had an issue before. This happened to me as well when I moved from an older atom based ubuntu install to a new i3 nuc, using a snapshot. the old box worked fine, took a full hassio snapshot, on the new box set up hassio, and then restored the snapshot. Could see everything running via the log, but no access via 8123. I had a zwave sensor that was - mis-behaving yesterday and that was why i triggered the restart that ended up with this issue. After which I removed z-wave from the core.config_entries to be sure it wasn’t the issue, and still was no way to recover.

I have the same issue, please may you tell me where can I find that file?
Thanks.

If you created a docker-compose yaml, you would know where it is. If you are using hassio, you don’t change anything.

What is the issue you are really having?