Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop the mosquitto (MQTT) broker from listening to a port using the command line

When I ran the Mosquitto (MQTT) broker for the first time there was no issue. But however from he second time when i ran it using default config I could not run the code successfully because of the following error:

1379497253: mosquitto version 1.2 (build date 2013-09-17 17:59:39+0530) starting 1379497253: Using default config. 1379497253: Opening ipv6 listen socket on port 1883. 1379497253: Error: Address already in use

I would like to know how to stop the broker from command line. It'll be nice if someone can help.

like image 711
user2430996 Avatar asked Sep 18 '13 08:09

user2430996


People also ask

How do I stop mosquitto MQTT?

On Windows you can stop the service if it is running by using the control panel>admin>services. By default the broker will start listening on port 1883.

How do I run mosquitto with config file?

conf and it is used by the mosquitto broker when started as a Linux daemon or Windows service. You will find the mosquitto. conf file in the /etc/mosquitto directory on Linux, and in the c:\mosquitto\ directory on Windows. Note: the Windows install lets you choose the directory.


3 Answers

If you don't know the PID, than you can use "pkill" instead of "kill" in linux. Command: "pkill mosquitto"

like image 170
KingAlex1985 Avatar answered Oct 19 '22 11:10

KingAlex1985


mosquitto starts to be a service.

sudo vi /etc/mosquitto/mosquitto.conf #more detail in `man mosquitto.conf`

sudo vi /etc/mosquitto/conf.d/custom.conf #add or change listening port as your need

sudo service mosquitto restart
like image 17
ileadu Avatar answered Oct 19 '22 12:10

ileadu


You don't say which OS you are using, but assuming it's Linux and you have mosquitto running in the background, you just use the kill command.

Use ps to find the pid of the currently running mosquitto instance then kill the pid.

like image 5
hardillb Avatar answered Oct 19 '22 11:10

hardillb