MQTT problems with Node-RED on macOS 13.2

Dear all!
I have an instance of the latest Node-RED Version: v3.0.2 with Node.js Version: v19.4.0 running on my M1 MacBook Pro with Darwin 22.3.0 arm64 LE just to try out things from time to time. It used to work like a charm.

Now MQTT does not work anymore.

What has happened in between? A lot... Among other things macOS 13.2 has arrived today.

What is happening now:

  • I start mosquitto in a shell, it is up and running:
    mosquitto version 2.0.15 running
  • a Tasmota device connects, MQTT broker reports it:
    New connection from 192.168.178.27:1557 on port 1883.
  • I start a Python script (new shell) connecting my Tinkerforge Hardware to the broker.
  • It connects to the broker on the same machine :
    MQTT bindings: Connected to MQTT broker at localhost:1883
  • MQTT broker reports that:
    New connection from 127.0.0.1:51208 on port 1883.
  • I START Node-RED in a third shell !!!
  • Node-RED logs
    [mqtt-broker:ea5e37ad8d4835c7] Verbindung zum Broker mqtt://localhost:1883 konnte nicht hergestellt werden ... Connection to ... could not be established.
  • the MQTT in/out nodes in Node-RED are stuck trying to connect (yellow squared box).

Why?

  • The MQTT config item in Node-RED is well defined and remained unchanged ...
  • I can connect to the MQTT broker from localhost with other tools.

What's wrong here? Any idea?
Cheers, Uwe

Since you have stated 172.0.0.1 can connect & Node-RED is failing to connect to localhost it suggests a networking issue. Try setting the broker connection in node-red to 172.0.0.1 instead of localhost

I will do so, but I think this is definitely not a networking issue. Resolving localhost works: my Python script connects successully to "localhost:1883" and the MQTT broker reports the new connection from 127.0.0.1.
No clue ...

I've seen similar issues.
They were related to the definition of localhost - being either IP6 or IP4.
I'd propose to check your definition within the node.js environment; my bet: it's IP6 (::)... whereas all others are defined as IP4.
The easiest way to solve: Let the node explicitly connect to mqtt://127.0.0.1:1883.

Being a Mac owner myself, I’d suggest getting a pizerow and installing mosquito on it. Then just point the mqtt nodes on your mac at the ip address of the pizerow. That’s how I’ve had my broker running for over two years.

Oh and if you install netatalk on the pi you can access the pi from the finder on the Mac. If you are interested I can send you my write up on what I do to install netatalk on my pi’s and how I configure it.

1 Like

Amazing ... changing localhost to 127.0.0.1 did the trick.
Looks like the stuff Node-RED relies on works now differently than it used to.
Concluding "localhost works, so the lower layers of networking work" is not valid.
Thanks & Cheers, Uwe

Actually it is a change in nodejs that is tripping things up - they now (node18+) prioritise ipv6 DNS lookups over ipv4