Node-red-contrib-home-assistant-websocket not connecting to Home Assistant

I’m facing an issue connecting node-red-contrib-home-assistant-websocket to my Home Assistant. The logs show an entry, every 5 seconds

[info] [server:Home Assistant] Connecting to http://homeassistant:8123

My install is all managed with docker-compose, Home Assistant and node-red are in the same docker network. From either container I can ping/curl the other, but no matter what I’ve tried I don’t seem to be able to get node-red to connect to HA. If it matters, node-red happily connects to a MQTT server also running in the same docker network.

HA - 0.114.3
node-red - 1.1.3
node-red-contrib-home-assistant-websocket - 0.24.1

Have you created the server node and defined the long live token that NR needs to connect with HA?
I have the same setup (so not Supervised version but “independent” docker images) and you have to do this manually. I use the IP address of my host in the node definition (not the “private” docker one).

Yes, I have generated a LLT for node-red.

“Base URL” configurations in the server node I have tried:

  • localhost (after exposing port 8123 of the HA container on the host)
  • local network IP of host (also with :8123 exposed on host)
  • docker-compose hostname, http://homeassistant:8123
  • external hostname (SSL, routed to HA via traefik), (desktop app and mobile apps use this just fine)

For HA I am using the official docker image, which has several ports exposed in it, so routing it via the host or mapping those ports should not be needed at all :

You can try using the websocket node to see if the NR container can connect to the HA container.


[{"id":"63fd141b.a639cc","type":"websocket in","z":"ffbd7f06.4a014","name":"","server":"","client":"b1b4ae82.ebd5c","x":328,"y":1312,"wires":[["a7726f6d.f83fd"]]},{"id":"a7726f6d.f83fd","type":"debug","z":"ffbd7f06.4a014","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":598,"y":1312,"wires":[]},{"id":"b1b4ae82.ebd5c","type":"websocket-client","z":"","path":"ws://homeassistant:8123/api/websocket","tls":"","wholemsg":"false"}]

You should get a response something like

{"type": "auth_required", "ha_version": "0.114.3"}

that connects :\

Ok, thoroughly confused now, on a whim, I flipped my HA config node over to use “Legacy API Password” and deployed. Got an error in the logs, as expected. But when I unchecked that option and redeployed, it connected…

I was actually battling this yesterday!

First thing to point out is you need to click “Deploy” in the top right after inserting HA details. I assumed clicking “done” was enough.

Second thins is a complete guess, but I feel like I needed to click “OK” to confirm the Long Life Token create (had it open so I could refer to it) and restart HA to get it working.

Also I have HA on host networking, so I had to use the host IP address.

:white_check_mark: yep, doing this

:white_check_mark: also this

That opens up a whole other host (terrible pun, I’m so sorry :joy:) of issues in my network. My Docker host is responsible for a fair other number of workloads, running host networking just isn’t in the cards.

And, I actually figured it out, a setting I forgot to change, I had removed the ip_ban_enabled setting this afternoon, but hadn’t actually checked it till the evening. Checking in ip_bans.yaml indeed lists a docker network IP :man_facepalming:

Thanks for reminding me; my container IP was also blocked :stuck_out_tongue:
I opened up the file and removed the entry and nodered connected.

I was banging my head against the wall with this last night. This makes absolutely no sense, but it worked. How can I create code to deploy if I can’t assign devices to nodes? It makes no sense! But all is well now that I clicked deploy on a flow with a single device node sitting in it. Thank you so much! I created an account just to say that… I don’t care that I am reviving this thread, since it is clearly still a hang-up that can happen today.

1 Like