In prior versions I had used "localhost" in the configuration and it works great. This time I imported nodes from the same version v3.0.2 but as a new Node-RED install, I installed nodes, I thought perhaps a version change is coming in this download?? MQTT nodes are installed as part of Node-RED. So this is what makes it somewhat confusing. On one system I can use the term "localhost" and the other I have to use "127.0.0.1".
Also, on the new system is an upgrade on this system from 2.?? to 3.0.2. The older version loaded on this one used "localhost" with the MQTT Configuration node just fine. There is a version difference issue pertaining to syntax perhaps in the MQTT Configuration node itself.
Not "fixed" but I have to use 127.0.0.1. When I ported code to it MQTT raised errors all over the place. I went around and around . rinse/repeat. until I just plugged in the 127.0.0.1 for a test. WOW! it worked. But that's not cool that only a different version and no other changes cause this.
It isn't that they changed localhost, it is, I believe, that for any name that supports both ipv6 and ipv4 nodejs will prefer ipv6.
Normally, on Linux, localhost maps to 127.0.0.1 (at least it does on mine), so localhost is the same as 127.0.0.1, presumably your Windows system is giving the option of that or an ipv6 address, and nodejs is using the ipv6 address.
What does ping localhost
I could be wrong but I think that nodejs resolving to ipv6 instead of ipv4 (in this case) is that the ops OS is actually also resolving to ipv6. In earlier versions of nodejs I believe it would have return an ipv4 address.
I had not realised that was an answer to the ping localhost question. In that case, yes, if ping only returns an ipv6 address for localhost then it is indeed windows that is doing that, nothing to do with nodejs or node-red. If the OS only provides an ipv6 address then that is what they must use.
No. (Sorry for indignation). Prior version of Node.js renders using "localhost" working. Change to 18 from 14 and now I need to specify '127.0.0.1'. So Windows is the common element. Node.js is different.
No apology necessary, as I see you are correct, Windows does provide the IPV6 for localhost. On my (linux) system the default install of mosquitto works perfectly with IPV6. Which MQTT broker are you using?
Yes, I know. Hopefully we may get an answer so we know how to answer this question in the future.
My experience is that the default mosquitto install on Ubuntu does not need adjusting for IPV6. It would be good to know if the default install on Windows does not support IPV6, or perhaps @hp_apcc is not using Mosquitto.
I expect there are other edge-cases I've not allowed for as well. As you can see ::1 is the IPv6 equivalent of localhost.
I know this isn't exactly what the problem is here but it may help where people are making assumptions about what might be seen as localhost. The important thing to note is that the representation of localhost is not purely dependent on one thing.