# Mosquitto (MQTT) - Client connection from \[ip address\] denied access by tcpd

**URL:** https://discourse.nodered.org/t/mosquitto-mqtt-client-connection-from-ip-address-denied-access-by-tcpd/62699
**Category:** General
**Tags:** mqtt
**Created:** [16 May 2022 14:53 UTC](https://discourse.nodered.org/t/mosquitto-mqtt-client-connection-from-ip-address-denied-access-by-tcpd/62699 "2022-05-16T14:53:41Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![alex88](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alex88/32/55523_2.png) [@alex88](https://discourse.nodered.org/u/alex88)
#### Post date: [16 May 2022 14:53 UTC](https://discourse.nodered.org/t/mosquitto-mqtt-client-connection-from-ip-address-denied-access-by-tcpd/62699/1 "2022-05-16T14:53:41Z")

</div>

Hi All,

Referring to this post, which is closed now: [MQTT "close timeout" issue using Aedes - #14 by Steve-Mcl](https://discourse.nodered.org/t/mqtt-close-timeout-issue-using-aedes/57583/14)

I've had a few instances over the past two days where NR has stopped working as expected.

I've done restarts and it's gone back to "normal", however when it happened for the 3rd time today, I had to dig deeper.

The issue appears to relate to MQTT messages not being sent/received, so I decided to check the mosquitto log, using this command (thank you to @Colin for sharing that command in the previous post, above):

```auto
sudo tail -f /var/log/mosquitto/mosquitto.log

```

To find an error message that is being reported through my searches to related to too many open files, presumably above the 1024 limit.

I have found a few articles on how to fix it (a couple cited below), but as is the case, they advise different methods to resolve the issue:

> <https://serverfault.com/questions/628610/increasing-nproc-for-processes-launched-by-systemd-on-centos-7>

> <https://stackoverflow.com/questions/38888914/mosquitto-denied-access-by-tcpd>

I am hoping there is someone on the forum that knows the "best" way to do this, else I'll do some more research and go down the trial and error path.

Thanks in advance for any help!

**EDIT: I've had a go and added the following line to /usr/lib/systemd/system/mosquitto.service:**

```auto
[Service]
LimitNOFILE=49152

```

then ran these...

```auto
sudo systemctl daemon-reload
sudo service mosquitto stop
sudo service mosquitto start

```

I just ran this after a restart to see the count of open connections:

```auto
sudo netstat -natp | grep ESTABLISHED.*mosquitto | wc -l

```

The count was 348. I will keep an eye on it, now that I know to run the command and see if it goes over 1,024, in which case the issue was related to the max number of open files.

Would still appreciate a steer if I'm headed down the wrong path

Cheers

---

<div class="post-metadata">

### Author: ![juntiedt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/juntiedt/32/58357_2.png) [@juntiedt](https://discourse.nodered.org/u/juntiedt)
#### Post date: [16 May 2022 18:04 UTC](https://discourse.nodered.org/t/mosquitto-mqtt-client-connection-from-ip-address-denied-access-by-tcpd/62699/2 "2022-05-16T18:04:21Z")

</div>

I had problems with Mosquitto as well. My shellies did not report mqtt messages any more. I tried many things but it did not work. Finaly I found a report at stackoverflow:  
`sudo service mosquitto stop`  
`sudo rm /var/lib/mosquitto/mosquitto.db`  
`sudo service mosquitto start`  
after I did this all worked perfectly again 🙂

---

<div class="post-metadata">

### Author: ![alex88](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alex88/32/55523_2.png) [@alex88](https://discourse.nodered.org/u/alex88)
#### Post date: [16 May 2022 18:42 UTC](https://discourse.nodered.org/t/mosquitto-mqtt-client-connection-from-ip-address-denied-access-by-tcpd/62699/3 "2022-05-16T18:42:07Z")

</div>

Hey @juntiedt, that's interesting. It implies there was an error in the mosquitto db.

I'll back up the db, in case, and try out your suggestion in a week or so (if mqtt stops working again). I want to first let my last change settle in.

I haven't done anything on the system since earlier today, but the count of open files is still sitting at 348, which is a bit odd... maybe I'll have to try out your suggestion. let's see.

---

<div class="post-metadata">

### Author: ![alex88](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alex88/32/55523_2.png) [@alex88](https://discourse.nodered.org/u/alex88)
#### Post date: [16 May 2022 19:15 UTC](https://discourse.nodered.org/t/mosquitto-mqtt-client-connection-from-ip-address-denied-access-by-tcpd/62699/4 "2022-05-16T19:15:10Z")

</div>

@juntiedt

I spoke too soon.

It happened again i.e. in my case, a complete system malfunction. Still only 348 connections.

I've tried out your suggestion 🤞

If it doesn't work, I'm up the proverbial without a paddle....

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [16 May 2022 22:33 UTC](https://discourse.nodered.org/t/mosquitto-mqtt-client-connection-from-ip-address-denied-access-by-tcpd/62699/5 "2022-05-16T22:33:32Z")

</div>

Hmm, I wonder what you are doing. My live home automation system shows 8 connections only.

Presumably you must have a lot of directly connected devices? Are they perhaps sometimes disconnecting and not restarting with a clean session?

Oh, I forgot, I've still got 5 other connections on my old Pi2 broker. That is bridged to my live server. Thought 8 seemed a bit low 😸

What version of Mosquitto do you have installed?

---

<div class="post-metadata">

### Author: ![alex88](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alex88/32/55523_2.png) [@alex88](https://discourse.nodered.org/u/alex88)
#### Post date: [17 May 2022 11:25 UTC](https://discourse.nodered.org/t/mosquitto-mqtt-client-connection-from-ip-address-denied-access-by-tcpd/62699/6 "2022-05-17T11:25:00Z")

</div>

@TotallyInformation

Yes, lots of individual devices on my flows. When I looked into mqtt it seemed to be setup for volume, so rather than create centralised conduits for data transmission, I spilt it out.

It really works very well, barring the recent issue. Performance is great.

No, they don't randomly or otherwise disconnect. The entire mqtt service fails.

I think the suggestion above has fixed it... Fingers crossed.

---

<div class="post-metadata">

### Author: ![alex88](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/alex88/32/55523_2.png) [@alex88](https://discourse.nodered.org/u/alex88)
#### Post date: [17 May 2022 13:05 UTC](https://discourse.nodered.org/t/mosquitto-mqtt-client-connection-from-ip-address-denied-access-by-tcpd/62699/7 "2022-05-17T13:05:02Z")

</div>

post moved to a new thread here: [MQTT open files increasing on "Restart Flows"](https://discourse.nodered.org/t/mqtt-open-files-increasing-on-restart-flows/62777)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [31 May 2022 13:05 UTC](https://discourse.nodered.org/t/mosquitto-mqtt-client-connection-from-ip-address-denied-access-by-tcpd/62699/8 "2022-05-31T13:05:12Z")

</div>

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