On Windows, after configuring 127.0.0.1, the Mosquitto service can start normally after a reboot. However, when I set it to my static IP, the service fails to start automatically. I then used a startup batch script: if the Mosquitto service is not running, the script attempts to restart it with the command sc.exe start "mosquitto". This command requires administrator privileges, which prevents full automatic startup when Windows boots. Could you tell me why the service fails to start when using a static IP?
Hi,
The Mosquitto service on Windows may fail to start automatically with a static IP due to timing issues during boot, where the network stack and IP assignment are not guaranteed to be ready when the service starts. This causes Mosquitto to fail binding to the static IP, while it reliably binds to 127.0.0.1 because the loopback interface is always ready.
Ideas:
Either do not use a fixed IP in your “listener” configuration.
so e.g. plain
listener 1883
Or you can make Mosquitto dependent on the start of the DHCP service.
sc config mosquitto depend=Dhcp
This makes Mosquitto wait for the IP address to be assigned before starting automatically.
I hope this helps!