MQTT "Error: Connection refused"

Hello Guys,

I run in some trouble and I hope you willo be able to help me.

I’m following How-To Get Started with Mosquitto MQTT Broker on a Raspberry Pi - YouTube
“How-To Get Started with Mosquitto MQTT Broker on a Raspberry Pi” videoand I have some issue with command “sudo mosquitto_sub -d -u mosquitto -P mypassword -t “dev/test”” i’m getting “Error: Connection refused”

I did some googling and if I run command “mosquitto -d” before any other command it starts working but that doesn’t make any sense for me and also if raspberry will be restarted it will stop working again :confused:


mosquitto -d

Is used to start the mosquitto daemon from the command line (much like sudo service mosquitto start) so it sounds like you just need to enable the mosquitto service to start at boot time. Try this command

sudo systemctl enable mosquitto.service

sorry but still doesn’t work :confused:

Did you ever get it working without the need for the mosquitto -d command? I’m having the same issue.

I tried ~$ sudo systemctl enable mosquitto.service, but this didn’t correct the error message “Error: Connection refused”.
However, ~ $ mosquitto -d worked.
Thank you zeeuk for your post.

Had the same problem. Solved it simply by deleting the log-file. It was created new and my demon accepts connections.

where is the log file?

Hi, welcome.

The mosquitto log? What is your system? emonPi?

Have you looked in the log folder?


can u call me pls

No. this is not a help desk it is a volunteer community. I am in the UK.


never mind… i got it… you could of asked for a skype…


Brian and the rest of us here, who between us put quite a lot of time and effort into answering the questions and solving the problems here, do so freely and without the expectation of anything more than an occasional ‘thank-you’. I know you’re new here, but expecting someone half-way around the world to spend time chatting to you is not something we are prepared to do.

There’s a huge amount of information on this website and the associated ones, and there’s a search function too. If looking at the guides and searching the forum for someone with a similar problem doesn’t help, we’re only too happy to help you. But just remember, you’re not the only one who needs our help.


wow. i guess i subscribed to the wrong community



I hope you know that you are being rude and expecting someone to do help you 24/7 is unacceptable, you are lucky to get a reply from a person who might be busier than you. Please be kind :slight_smile:


Welcome to the OEM forum, Rohan.

Thank you for the support. Happily, we encounter very few comments like the one you are referring to. Equally happily, the number of people who say thank-you greatly outnumber people like Ari.

Or, in the words of a notice at an airfield somewhere in the UK: “Some people create pleasure by their arrival, others by their departure.”