mosquitto MQTT: No connection could be made because the target machine actively refused it

11,085

Solution 1

I had the that problem. I saw a solution (in Windows), and it helped me.

Go to Services (it is also called Services.msc) and search for the "Mosquitto Broker" service, and click on "start (the) service".

service_window_picture

Solution 2

The version of Moquitto you are running is very old (the latest is 1.4.1) and I think that version only supports protocol 3.0 not 3.1.1

Best bet will be to upgrade to the version 1.4.1. There are details on how to add a new apt repository to get the latest version on the mosquitto download page here: http://mosquitto.org/download/

Solution 3

Thanks to the help from one of the folks on this forum (hardillb), I realized that my version of mosquitto did not support protocol 3.1.1. After updating --by running the commands below - it has solved the connection problem on my RaspberryPi with Derbian

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-wheezy.list
apt-get update
apt-get install mosquitto
Share:
11,085
Ivan Sager
Author by

Ivan Sager

Updated on July 25, 2022

Comments

  • Ivan Sager
    Ivan Sager almost 2 years

    I'm using c# MQTT Client clientSub = new MqttClient("raspberrymachine100");

    and when I connect with this C# client, I get the error {"No connection could be made because the target machine actively refused it 192.168.12.134:1883"}

    But when I use the same C# client and connect to host test.mosquitto.org I am able to connect.

    Additionally, when I use the mosquittto installed client "C:\Program Files (x86)\mosquitto\mosquitto_sub" -h 192.168.12.134 -p 1883 -d -t /topic/test This above line works fine and I can subscribe

    Any thoughts?

  • Ivan Sager
    Ivan Sager about 9 years
    hardillb - many thanks for the info. I ran the steps below and YEAH, its working now..Appreciate your help.