2

I have a Mosquitto broker running on my Windows machine. I can connect to this on the same machine using an MQTT client such as MQTTX when I specify localhost as the address.

However, I want other devices on my local network to be able to connect also to this using the local IP address of my Windows computer.

Even when I specify the local IP address in the MQTT client application instead of localhost, this does not work and I get Error: connect ECONNREFUSED . I have port 1883 publicly open on my Windows computer also. Any ideas?

3 Answers 3

3

I use homebridge, but I found the same problem.

On the pi MQTT broker, set "allow_anonymous true" in your mosquitto.conf file, it allows clients to connect to the MQTT broker without any authentication.

use the /var/log/mosquitto/mosquitto.log to check if they are connect.

Just keep in mind that allowing anonymous access to your broker is not recommended in production environments. It may be useful for testing and development purposes though.

2

See this Answer to basically the same question on Stack Overflow

https://stackoverflow.com/a/65278769/504554

For full details read the Mosquitto V2.0.0 release notes.

Basically you need to supply a config file explicitly allowing connections from anywhere other than localhost as part of an improved default security posture from mosquitto.

You also need to explicitly disable requiring a username and password to connect if you want anonymous clients to work.

0

add a below code only in configuration file

listener 1883 0.0.0.0
allow_anonymous true

run this command in command prompt run as administrator mosquitto -v -c your_config_filenmae.conf (example:mosquitto.conf)

and move to the mosquitto directory cmd and navigate your sub and pub commands

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.