Docker: Homeassistant server setup in node-red not working

Hey i have tried almost everything, so now i try here
My problem is that i have Home-assistant and Node-red in two different containers, and im trying to connect to Home-assistant through Node-red by connection to the Home-assistant. But nothin works i keep getting diffrent fail messages. i have tried diffrent pallets in node-red that i could find for home-assistant. Please help Bonus info im running all of this on a Raspberry pi 4 model b
homeassistant prob 1
I hope the picture help to understand my problem. im new to all this Raspberry pi and to coding :slight_smile:

1 Like

The way got it to work with two containers was to use network:host for both docker configs and using the hostname or host IP addresss for base url not localhost.

You’re using the most recent version of node-red-contrib-home-assistant-websocket, right?

i believe i do since i just installed it and have updated

I have tried that, but it dindt work for me, how excatly did u do it?

Please send a screenshot of the nodes you have installed in “Manage palette”.

I have a similar problem here…
Running Node-RED and Home Assistant in docker containers under on a NUC with Ubuntu.
Trying to config Node-RED following several instructions i’ve found, such as these, I Configured the HA Server (I think) correctly with it URL and port, and the HA Long Lived Access Token:

Here, I just leave everything “as is” and click Done.

When I then deploy, I get the message:

When I Confirm Deploy, I get a message Successfully deployed but the node stays on a yellow Connecting:
Screenshot 2021-10-05 at 23.08.54

What am I missing here ?

Specify an entity_id.

The HA nodes in NR are not successfully connecting to Home Assistant. Check the NR logs. On a success connection the status under the events: state will be a solid green box with the text running

Well, the NR logs are not very helpful:

nodered     | 6 Oct 13:16:35 - [info] Stopping flows
nodered     | 6 Oct 13:16:35 - [info] Stopped flows
nodered     | 6 Oct 13:16:35 - [info] Starting flows
nodered     | 6 Oct 13:16:35 - [info] Started flows
nodered     | 6 Oct 13:16:35 - [info] [server:Home Assistant] Connecting to

That’s all !

I checked and re-checked but it’s still the same…

Yep, tried that already:

Doing so I got rid of that annoying message but still no cure… The NR logs don’t say much… I’m new to NR, don’t know it it’s possible to toggle more verbose logs or debug mode?

6 Oct 15:27:36 - [info] Stopping flows
6 Oct 15:27:36 - [info] [server:Home Assistant] Closing connection to
6 Oct 15:27:36 - [info] Stopped flows
6 Oct 15:27:36 - [info] Starting flows
6 Oct 15:27:36 - [info] Started flows
6 Oct 15:27:36 - [info] [server:Home Assistant] Connecting to
6 Oct 15:27:39 - [info] [server:Home Assistant] Connecting to

I don’t use the docker version so I am not sure how to change the log output. You could start with deleting the server, deleting the token, reboot everything, then new token, new server.

1 Like

So first, I would ask - is your home assistant install really available on http or do you have to use https?

Next, I would check the logs in Home Assistant, it’s quite good at telling you about connection attempts it rejected.

I would also ask did you generate a token under your own user account or did you create a home assistant user for NodeRed to use? If you created a user, according to the official documentation for the node, the user MUST be in the Administrators group.

Do you have the ip_ban filter enabled in your Home Assistant config, if so - it may have banned the Docker IP that NodeRed is connecting from.

1 Like

My HA is readily availaible on http://, not https:// .
When I try to connect from NR, I don’t see anything in the HA logs. This could mean that the request from NR never reaches HA for some reason…
I generated the token under my own “Owner” account, which is of course administrator. May I should try with a “normal” (E.g. not the Owner) administator account…
I did not enable the ip_ban filter (unless it is enabled by default?).
Will continue searching…

In which case, the next thing I would try would be a web request node, and try to make it access your home assistant instance - just to see if the node times out connecting, or actually returns the login page. Dump the whole msg object, not just the payload - to a debug node (that will give us access to status code and other stuff)

I use node red in docker and pretty much followed the linked guide below. I made a separate “node red” user in Home Assistant and generated the token under that, per the guide’s directions.

Also make sure you define a persistent volume and map open port 1880. You can try posting your docker run command or compose to check that.

You have Home Assistant running in host networking mode too right?

Sorry, had to be away from this for a couple of weeks… Here are my docker-compose.yml files (yes, I know , two files, just for the moment to keep things easier for me to manage :upside_down_face: )

Home Assistant:

version: '3'
    container_name: homeassistant
    image: homeassistant/home-assistant:stable
      - ./config:/config
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock
      # Conbee II Zigbee device on USB
      - /dev/ttyACM1:/dev/ttyACM1
    restart: unless-stopped
    network_mode: host

And NodeRED:

version: '3.7'

    container_name: nodered
    image: nodered/node-red:latest

      - TZ=Europe/Brussels

      - "1880:1880"

    restart: unless-stopped

      - ./data:/data

I do two compose files as well. Since they’re not technically on the same docker network since Home Assistant is in Host mode, it doesn’t really matter.

My node red compose has some extra info for volumes, but I’m not sure it makes a difference for your install:

version: '3.7'
    build: .
    container_name: "node-red"
      TZ: America/New_York
    image: "nodered/node-red"
    restart: always
      - "1880:1880"
      - "data:/data"
    name: node-red_data
    driver: local-persist
      mountpoint: /node-red/data

This is my config node (with access token removed). Make sure your entire access token is in there - the whole thing it is super long and has a . somewhere in it, so you might think you copied all of it but might have missed a part.

Also spell out the IP of the machine home assistant is on. Don’t use or localhost as that will just loop back to the docker container Node red is in and won’t get to the Home Assistant instance. Make sure “I use the Home Assistant Add-on” is not checked since you’re running in docker and not using the addon.

Screenshot from 2021-10-27 11-28-46

I also checked my logs, so if successful, you will see

27 Oct 11:10:30 - [info] [server:Home Assistant] Connecting to
27 Oct 11:10:30 - [info] [server:Home Assistant] Connected to

Thank you !
I checked everything and did the change to docker-compose.yml as you suggest, but still the same.

I must say, I’m still ar rookie level on docher… What do these instructions do? I Found them in some example files for node-RED but not in others…

I think that was the old way you had to define a “persistent volume” in docker, but newer versions of docker you can just define the volume either as a mapped directory or a named volume without needing to specify the driver.

If volumes are mapped directories, ie something like

            - '/home/user/docker/zwave/store:/usr/src/app/store'

The data for the container will persist in the directory on the host outside docker and map to the folder path within docker.

If the volume was defined with a name, like

            - 'portainer_data:/data'

Then those volumes should be in /var/lib/docker/volumes

All the info on volumes is here.

The Node red volume is the only one I have that does is with this “local-persist” driver. It’s working though so I haven’t changed it.

Not sure why it’s still not working. Are they both installed on the same machine? There could be some other config problem with Node red I’m not aware of, but either there’s a network issue or something wrong with the token are my best guesses.