# MQTT retaining unwanted messages

**URL:** <https://discourse.nodered.org/t/mqtt-retaining-unwanted-messages/39163>\
**Category:** General\
**Created:** [14 January 2021 23:50 UTC](https://discourse.nodered.org/t/mqtt-retaining-unwanted-messages/39163 "2021-01-14T23:50:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nksky](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nksky/32/9173_2.png) [@nksky](https://discourse.nodered.org/u/nksky)\
**Post date:** [14 January 2021 23:50 UTC](https://discourse.nodered.org/t/mqtt-retaining-unwanted-messages/39163/1 "2021-01-14T23:50:10Z")

</div>

I have a simple flow, Ubuntu server, 2 Pi-4 Clients. Communication via MQTT between clients and server.  
On the server I set the MQTT out node to "Retain Message", so when the client would start it would get the last message. It worked. I no longer need this, but even though I unclicked "Retain Messages", then clients are always pulling a message.

Is there some cache I need clear or what have I missed!!!

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 January 2021 00:11 UTC](https://discourse.nodered.org/t/mqtt-retaining-unwanted-messages/39163/2 "2021-01-15T00:11:05Z")

</div>

To clear a retained message on a topic, you need to publish an empty payload with the retain flag set.

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [15 January 2021 04:33 UTC](https://discourse.nodered.org/t/mqtt-retaining-unwanted-messages/39163/3 "2021-01-15T04:33:34Z")

</div>

Install the mosquitto-clients package. Then you can send the empty message to your server with the retain bit set from the command line:

mosquitto\_pub -h your\_server -t "yourTopic" -m "" -r

I find this easier and quicker than doing something with a flow.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 January 2021 07:28 UTC](https://discourse.nodered.org/t/mqtt-retaining-unwanted-messages/39163/4 "2021-01-15T07:28:27Z")

</div>

Using MQTT explorer, you can select the retained item from the tree & simply click the delete button.

---

<div class="post-metadata">

**Author:** ![nksky](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nksky/32/9173_2.png) [@nksky](https://discourse.nodered.org/u/nksky)\
**Post date:** [18 January 2021 23:49 UTC](https://discourse.nodered.org/t/mqtt-retaining-unwanted-messages/39163/5 "2021-01-18T23:49:08Z")

</div>

Is MQTT explorer in Node-Red or is it an external app?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [18 January 2021 23:50 UTC](https://discourse.nodered.org/t/mqtt-retaining-unwanted-messages/39163/6 "2021-01-18T23:50:33Z")

</div>

External application for browsing / viewing your MQTT broker (very professional & user friendly)

---

<div class="post-metadata">

**Author:** ![nksky](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nksky/32/9173_2.png) [@nksky](https://discourse.nodered.org/u/nksky)\
**Post date:** [19 January 2021 00:04 UTC](https://discourse.nodered.org/t/mqtt-retaining-unwanted-messages/39163/7 "2021-01-19T00:04:46Z")

</div>

Wow, Very good program, handy to have, serious information in it. Thank you.

---

<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:** [2 February 2021 00:04 UTC](https://discourse.nodered.org/t/mqtt-retaining-unwanted-messages/39163/8 "2021-02-02T00:04:48Z")

</div>

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