3

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?

4 Answers 4

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

0

To configure Mosquitto with a listener on port 1883, allowing anonymous access, follow these steps:

Open your Mosquitto configuration file (e.g., mosquitto.conf) and add the following lines:
        
listener 1883 0.0.0.0
allow_anonymous true
        
    
Save the configuration file. Open the command prompt as an administrator. Navigate to the Mosquitto directory using the cd command:
        
cd path\to\mosquitto
        
    

Start Mosquitto with the configured file using the following command:


mosquitto -v -c your_config_filename.conf

(Replace your_config_filename.conf with the actual name of your configuration file, e.g., mosquitto.conf)

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