# Mosquitto MQTT Broker Issue

**URL:** <https://community.cumulocity.com/t/mosquitto-mqtt-broker-issue/1073>\
**Category:** Forum\
**Tags:** analytics, cumulocity-edge, thin-edge-io, cumulocity, device-connectivity\
**Created:** [December 15, 2023, 10:56am UTC](https://community.cumulocity.com/t/mosquitto-mqtt-broker-issue/1073 "2023-12-15T10:56:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aneel\_Chaladi](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@Aneel\_Chaladi](https://community.cumulocity.com/u/Aneel_Chaladi)\
**Post date:** [December 15, 2023, 10:56am UTC](https://community.cumulocity.com/t/mosquitto-mqtt-broker-issue/1073/1 "2023-12-15T10:56:59Z")

</div>

Hi ,

while i am trying to do below command i am followings error. How can i resolve this

sudo tedge connect c8y

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/b/2/b236d113c76f3f9aeace891aa7b3ca448e159ad0.png)

---

<div class="post-metadata">

**Author:** ![Reuben\_Miller2](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/reuben_miller2/32/317_2.png) [@Reuben\_Miller2](https://community.cumulocity.com/u/Reuben_Miller2)\
**Post date:** [December 15, 2023, 11:16am UTC](https://community.cumulocity.com/t/mosquitto-mqtt-broker-issue/1073/2 "2023-12-15T11:16:53Z")

</div>

Some more details would be useful here, as there could be a number of reasons why mosquitto is failing to run.

Can you please provide the following information?

- Which mosquitto version are you using, check by running `mosquitto -h`
- What are the contents of your mosquitto config file? `cat /etc/mosquitto/mosquitto.conf`
- What files do you have under /etc/tedge/mosquitto-conf? e.g. `ls -l /etc/tedge/mosquitto-conf/`
- How did you install [thin-edge.io](http://thin-edge.io)? Did you install it via our install script (e.g. `wget -O - thin-edge.io/install.sh | sh -s`)

However to debug mosquitto it might be more helpful if you try running the mosquitto command manually, and then view what the output is. Assuming that the `mosquitto` service is stopped, you can then run mosquitto locally using:

```sh
sudo mosquitto -c /etc/mosquitto/mosquitto.conf

```

Then observe the output to see what is going on.

---

<div class="post-metadata">

**Author:** ![Aneel\_Chaladi](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@Aneel\_Chaladi](https://community.cumulocity.com/u/Aneel_Chaladi)\
**Post date:** [December 15, 2023, 11:37am UTC](https://community.cumulocity.com/t/mosquitto-mqtt-broker-issue/1073/3 "2023-12-15T11:37:13Z")

</div>

Please find details as below

Which mosquitto version are you using, check by running mosquitto -h **(2.0.11)**  
What are the contents of your mosquitto config file? cat /etc/mosquitto/mosquitto.conf **(No Such Directory)**  
What files do you have under /etc/tedge/mosquitto-conf? e.g. ls -l /etc/tedge/mosquitto-conf/ **((No Such Directory))**  
How did you install [thin-edge.io](http://thin-edge.io)? Did you install it via our install- script (e.g. wget -O - [thin-edge.io/install.sh](http://thin-edge.io/install.sh) | sh -s)

Installed via **“curl -fsSL [https://thin-edge.io/install.sh](https://thin-edge.io/install.sh) | sh -s”**

sudo mosquitto -c /etc/mosquitto/mosquitto.conf

![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/5/4/543dd5e8b6e3c506ed90a63965d749c44d3910e1.png)

---

<div class="post-metadata">

**Author:** ![Aneel\_Chaladi](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@Aneel\_Chaladi](https://community.cumulocity.com/u/Aneel_Chaladi)\
**Post date:** [December 15, 2023, 11:46am UTC](https://community.cumulocity.com/t/mosquitto-mqtt-broker-issue/1073/4 "2023-12-15T11:46:39Z")

</div>

while trying below command i got fallowing error

```auto
**sudo mosquitto -c /etc/mosquitto/mosquitto.conf**

```

```auto

```

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/8/6/8622f6dcc410fb5f8cf5414ef200da0088a5c8f5.png)

---

<div class="post-metadata">

**Author:** ![Reuben\_Miller2](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/reuben_miller2/32/317_2.png) [@Reuben\_Miller2](https://community.cumulocity.com/u/Reuben_Miller2)\
**Post date:** [December 15, 2023, 12:00pm UTC](https://community.cumulocity.com/t/mosquitto-mqtt-broker-issue/1073/5 "2023-12-15T12:00:04Z")

</div>

Please read the instructions carefully and use copy/paste rather than typing the commands, as you’ve mixed up a lot of the commands, and it is a bit unclear what the current state is.

---

<div class="post-metadata">

**Author:** ![Reuben\_Miller2](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/reuben_miller2/32/317_2.png) [@Reuben\_Miller2](https://community.cumulocity.com/u/Reuben_Miller2)\
**Post date:** [December 15, 2023, 12:10pm UTC](https://community.cumulocity.com/t/mosquitto-mqtt-broker-issue/1073/6 "2023-12-15T12:10:02Z")

</div>

But generally google is also a good source of information to help debug mosquitto, here is a result that I found regarding the “Couldn’t open database”. [Broker corrupts persistent database mosquitto.db · Issue #424 · eclipse-mosquitto/mosquitto · GitHub](https://github.com/eclipse/mosquitto/issues/424)

So you must have some invalid mosquitto configuration for whatever reason. Try to simplify your setup:

1. Edit the mosquitto.conf file under `/etc/mosquitto/mosquitto.conf` and add the following contents (please paste exactly as it is)

2. Save the file, and exit the editor

3. Try starting mosquitto manually on the command line

---

<div class="post-metadata">

**Author:** ![Aneel\_Chaladi](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@Aneel\_Chaladi](https://community.cumulocity.com/u/Aneel_Chaladi)\
**Post date:** [December 15, 2023, 1:56pm UTC](https://community.cumulocity.com/t/mosquitto-mqtt-broker-issue/1073/7 "2023-12-15T13:56:53Z")

</div>

Please find the log details

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/e/a/eae7993a7a1ab33e69c63024fc1532f8dc457a0f.png)

---

<div class="post-metadata">

**Author:** ![Reuben\_Miller2](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/reuben_miller2/32/317_2.png) [@Reuben\_Miller2](https://community.cumulocity.com/u/Reuben_Miller2)\
**Post date:** [December 15, 2023, 4:21pm UTC](https://community.cumulocity.com/t/mosquitto-mqtt-broker-issue/1073/8 "2023-12-15T16:21:50Z")

</div>

It looks like you have something else running which is using port 1883 (most likely another instance of mosquitto running). Either the mosquitto service is running again, or you started another background instance of mosquitto via another shell.

You can check if the mosquitto (systemd) service is running

```sh
sudo systemctl status mosquitto

```

And if it output shows that the service is running, then maybe you don’t have a problem anymore, and then we can end the debugging. And if the service is showing it is not running, then you can just reboot your device to try to kill the extract unexpected process which is using port 1883 (if you don’t know how to use standard linux tools such as `pgrep` and `kill`).

Otherwise, if the problem still persists, maybe you’re running into the mosquitto bug where the mosquitto service is starting before the network has been established. Though see the mosquitto project for further details: [Mosquitto may fail to start on boot · Issue #2878 · eclipse-mosquitto/mosquitto · GitHub](https://github.com/eclipse/mosquitto/issues/2878)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [June 12, 2024, 4:22pm UTC](https://community.cumulocity.com/t/mosquitto-mqtt-broker-issue/1073/9 "2024-06-12T16:22:08Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
