Upgraded mosquitto to 2.0.22 Now can't Start Service (W11 Pro)

Hi I have been happily running mosquitto as a service for a couple of years on my Windows 11 computer. The version I was running was 2.0.18.

I recently upgraded, using this exe downloaded from mosquitto.org:
mosquitto-2.0.22-install-windows-x64.exe

I didn’t think to back up my folder in Program Files before I upgraded and was aghast that the install overlaid my mosquitto.conf file with a new one. The broker would start, after upgrade, and my subscriber (node-red) could subscribe, but my publisher (a mosquitto publisher running on a different device on the local network) couldn’t. I managed to dig out an old copy of my .conf file, and did a byte by byte compare. Other than carriage return format differences, it turns out the “new” .conf file is identical in every way except the entries I added. (simple things like a password file, and some logging, and denying anonymous connections, and which port to be listening on). Settings I gleaned from some tutorial a couple of years ago. So I first copied my settings into the new mosquitto.conf file. Later I tried overlaying the installed mosquitto.conf file with a copy of my old one.

I did the install as a service.

I can start mosquitto with a cmd entry like this (with or without -v) (and after making sure the service is stopped):
C:\Program Files\mosquitto>mosquitto -c mosquitto.conf -v

Everything starts up fine when I start interactively with command line–nothing that looks like an error is reported (see log below). But it won’t start as a service. It says “Windows is starting … service” and then immediately “… service stopped.” Here is a short log of the terminal window at successful startup.

C:\Program Files\mosquitto>mosquitto -c mosquitto.conf -v
2026-01-18T13:26:52: mosquitto version 2.0.22 starting
2026-01-18T13:26:52: Config loaded from mosquitto.conf.
2026-01-18T13:26:52: Opening ipv6 listen socket on port 1883.
2026-01-18T13:26:52: Opening ipv4 listen socket on port 1883.
2026-01-18T13:26:52: mosquitto version 2.0.22 running
2026-01-18T13:26:55: New connection from 192.168.6.100:49957 on port 1883.
2026-01-18T13:26:55: New client connected from 192.168.6.100:49957 as sbms (p2, c1, k60, u'electrodacus').
2026-01-18T13:26:55: No will message specified.
2026-01-18T13:26:55: Sending CONNACK to sbms (0, 0)
2026-01-18T13:26:55: Received PUBLISH from sbms (d0, q0, r0, m0, '/solar/battery/sbms', ... (464 bytes))
2026-01-18T13:26:56: Received PUBLISH from sbms (d0, q0, r0, m0, '/solar/battery/sbms', ... (465 bytes))
2026-01-18T13:26:56: Received PUBLISH from sbms (d0, q0, r0, m0, '/solar/battery/sbms', ... (462 bytes))
2026-01-18T13:26:57: New connection from 127.0.0.1:62325 on port 1883.
2026-01-18T13:26:57: New client connected from 127.0.0.1:62325 as nodered (p2, c1, k60, u'nodered').
2026-01-18T13:26:57: No will message specified.
2026-01-18T13:26:57: Sending CONNACK to nodered (0, 0)
2026-01-18T13:26:57: Received SUBSCRIBE from nodered
2026-01-18T13:26:57:    /solar/battery/sbms (QoS 2)
2026-01-18T13:26:57: nodered 2 /solar/battery/sbms
2026-01-18T13:26:57: Sending SUBACK to nodered
2026-01-18T13:26:57: Received PUBLISH from sbms (d0, q0, r0, m0, '/solar/battery/sbms', ... (463 bytes))
2026-01-18T13:26:57: Sending PUBLISH to nodered (d0, q0, r0, m0, '/solar/battery/sbms', ... (463 bytes))
2026-01-18T13:26:58: Received PUBLISH from sbms (d0, q0, r0, m0, '/solar/battery/sbms', ... (462 bytes))
2026-01-18T13:26:58: Sending PUBLISH to nodered (d0, q0, r0, m0, '/solar/battery/sbms', ... (462 bytes))
2026-01-18T13:27:00: Received PUBLISH from sbms (d0, q0, r0, m0, '/solar/battery/sbms', ... (462 bytes))
2026-01-18T13:27:00: Sending PUBLISH to nodered (d0, q0, r0, m0, '/solar/battery/sbms', ... (462 bytes))
2026-01-18T13:27:03: mosquitto version 2.0.22 terminating

It terminated because I ctrl-C’d it.

I’m obviously getting connected and it’s working fine from the cmd line. But as a service, it keeps stopping immediately. I don’t see any logging going on at all, where it was previously logging. I have done a bunch of googling, but haven’t found any answers yet. Anyone familiar with this issue on Windows? How do I get the service to tell me why it is stopping. Here are my active conf file entries (everything else is commented out).

listener 1883
log_dest stderr
log_type error
log_type warning
log_type notice
log_type information
connection_messages true
log_timestamp true
log_timestamp_format %Y-%m-%dT%H:%M:%S
allow_anonymous false
password_file passwdfile.pwd

The password file is there and properly encrypted. The previous incarnation was logging to C:\Program Files\mosquitto\Log\mosquitto.log (this must be a default location, as I don’t see that location specified anywhere). I renamed the old file and did not create a new one.

Here is the last entry in the old file, from before I upgraded.

2026-01-16T16:42:36: mosquitto version 2.0.18 starting
2026-01-16T16:42:36: Config loaded from C:\Program Files\mosquitto/mosquitto.conf.
2026-01-16T16:42:36: Opening ipv6 listen socket on port 1883.
2026-01-16T16:42:36: Opening ipv4 listen socket on port 1883.
2026-01-16T16:42:36: mosquitto version 2.0.18 running
2026-01-16T16:42:39: New connection from 192.168.6.100:60165 on port 1883.
2026-01-16T16:42:39: New client connected from 192.168.6.100:60165 as sbms (p2, c1, k60, u'electrodacus').
2026-01-16T16:43:26: New connection from 127.0.0.1:49724 on port 1883.
2026-01-16T16:43:26: New client connected from 127.0.0.1:49724 as nodered (p2, c1, k60, u'nodered').
2026-01-17T12:41:11: Client nodered disconnected.
2026-01-17T13:07:56: mosquitto version 2.0.18 terminating

I tried in the conf file to turn logging off, to see if that is the problem, by changing

log_dest none

But that didn’t change the startup issue.

Attached is the Mosquitto Broker Service configuration window.

Anyone familiar with this issue and know the solution? It’s probably simple, but I’m out of ideas.

After some more googling, I have found this that probably steps me through everything, to set things up properly, rather than throwing darts. If this doesn’t solve my issue, I’ll come back with new info.

OK, that page I linked was very helpful. But it still took me an hour of fiddling around to get it working as a service.

  1. The service is installed by the installer, but no mosquitto.conf file is put in the startup parameter for the service. I added this: -c “C:\Program Files\mosquitto\mosquitto.conf” as a startup parameter, and then started the service.
  2. The bat file I was using to “prove” it was configured correctly first set the directory to C:\Program Files\mosquitto and then started with parameter -c mosquitto.conf, but apparently the service doesn’t know where it is, so you need to specify the full path to the mosquitto.conf when starting the service, and if it is in Program Files, you need to use quotes around the file name (as above).
  3. The “as working” (I thought) backup of my saved mosquitto.conf file was apparently not the latest (after I got it working again as a service 2 years ago). So I needed to edit the file and change (what I had listed above) to use fully qualified file names WITHOUT quotes in the conf file. ie log_dest file C:\Program Files\mosquitto\log\mosquitto.log and password_file C:\Program Files\mosquitto\passwdfile.pwd
  4. Make sure your cmd-started instance of mosquitto is not running when you try to start the service again!

Hope this helps someone else!

Sorry to hear you’ve been having problems. First things first - I’ve just made a change so the installer won’t overwrite existing mosquitto.conf files in the future.

The broker automatically sets its own -c option when starting as a Windows service. It uses the MOSQUITTO_DIR environment variable as the directory where the mosquitto.conf file is to be found. If that environment variable wasn’t set, or was set incorrectly by the installer then that may well have caused your problems with it not starting.

Thanks! I do see the environment variable set correctly, but for some reason my broker wasn’t starting until I specified the full file path. Not sure why.

Interestingly, the full file path in starting the service must be in quotes because my mosquitto.conf file is in Program Files, but mosquitto didn’t like it at all when I put the file specs in the conf file in quotes.

Would have been “no drama” if I had saved notes and the .conf file when I finally got the broker as a service working last time!

Thanks again.