First of all, I must apologize, as this topic is most likely not directly related to Node-RED, but to Docker. But maybe you guys can help me anyway.
Node-RED is natively installed on a Raspberry Pi.
In parallel, an instance of Mosquitto is running in a Docker container.
I was always able to access the Mosquitto MQTT broker with localhost.
But after I had to completely rebuild the RPi, the connection only works via the real IP, i.e. 192.168.0.10 instead of also via localhost.
Unfortunately, I have absolutely no idea whether I have made a special setting for this, or whether this had worked out of the box.
I would rather not run the container on the network "host" on Docker.
This would allow me to address Mosquitto via localhost, but I'm sure I hadn't done it that way before the reinstall.
In that case localhost should map to 127.0.0.1, so I don't know why that would not work. I suspect it is to do with the way the docker container is setup, but I don't know what. Unless it is an ipv6 issue.
I read somewhere that especially the localhost in the line: ::1 localhost ip6-localhost ip6-loopback causes problems.
Now it's working like a charm again. Maybe the ip6 crap got in my way
EDIT:
By the way, this also works (removing just the localhost in the second line):