# balenaOS is listening to MQTT port 1883

**URL:** <https://forums.balena.io/t/balenaos-is-listening-to-mqtt-port-1883/35328>\
**Category:** balenaOS\
**Tags:** raspberrypi3\
**Created:** [October 3, 2019, 7:57am UTC](https://forums.balena.io/t/balenaos-is-listening-to-mqtt-port-1883/35328 "2019-10-03T07:57:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/janvda/32/1271_2.png) [@janvda](https://forums.balena.io/u/janvda)\
**Post date:** [October 3, 2019, 7:57am UTC](https://forums.balena.io/t/balenaos-is-listening-to-mqtt-port-1883/35328/1 "2019-10-03T07:57:44Z")

</div>

I have stopped all service and executed command `netstat -lt` in my host OS terminal window and it outputted the following.

```auto
root@ba7c427:~# netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State       
tcp 0 0 127.0.0.2:domain 0.0.0.0:* LISTEN      
tcp 0 0 10.114.102.1:domain 0.0.0.0:* LISTEN      
tcp 0 0 :::1883 :::* LISTEN      
tcp 0 0 :::48484 :::* LISTEN      
tcp 0 0 :::22222 :::* LISTEN      
root@ba7c427:~# 

```

So it appears to be listening to the standard MQTT port 1883.  
Is this normal and if so why is it listening to this port ?

I also think that this makes that my mqtt service failed to start.  
FYI here below the relevant extract from my docker-compose.yml specifying the mqtt service.

```auto
  mqtt:
    image: arm32v6/eclipse-mosquitto:1.6.2 #https://hub.docker.com/_/eclipse-mosquitto
    network_mode: host  
    ports:
      - "1883:1883"

```

and here below the log when I start the mqtt service:

```auto
03.10.19 10:01:49 (+0200) Restarting service 'mqtt sha256:30caf0d6fd5119b2aed22be3976c01a67b0d359896c4b249a8a8334b9c6070c1'
03.10.19 10:01:49 (+0200) mqtt 1570089709: mosquitto version 1.6.2 starting
03.10.19 10:01:49 (+0200) mqtt 1570089709: Config loaded from /mosquitto/config/mosquitto.conf.
03.10.19 10:01:49 (+0200) mqtt 1570089709: Opening ipv4 listen socket on port 1883.
03.10.19 10:01:49 (+0200) mqtt 1570089709: Error: Address in use
03.10.19 10:01:50 (+0200) Service exited 'mqtt sha256:30caf0d6fd5119b2aed22be3976c01a67b0d359896c4b249a8a8334b9c6070c1'

```

---

<div class="post-metadata">

**Author:** ![gelbal](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/gelbal/32/1109_2.png) [@gelbal](https://forums.balena.io/u/gelbal)\
**Post date:** [October 3, 2019, 2:06pm UTC](https://forums.balena.io/t/balenaos-is-listening-to-mqtt-port-1883/35328/2 "2019-10-03T14:06:53Z")

</div>

Hi @janvda, as far as I know balena doesn’t do anything special with port 1883 so it doesn’t listen to it by default. I have checked this on my RPi3 running the latest hostOS now and I don’t see the port 1883 listened.

Since your container does use this port, I wonder if that service is not exited fine. Maybe it’s still running although the supervisor thinks it exited. Could you please verify that? (`balena ps` command would show the running containers)

Next, it’d be useful to look further at the logs to see if there are any errors with stopping the service.

If you could grant us support access and share the device UUID, we’d be glad to take a further look here.

Cheers…

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/janvda/32/1271_2.png) [@janvda](https://forums.balena.io/u/janvda)\
**Post date:** [October 3, 2019, 3:00pm UTC](https://forums.balena.io/t/balenaos-is-listening-to-mqtt-port-1883/35328/4 "2019-10-03T15:00:43Z")

</div>

I have rebooted my device and the issue is gone.  
So I guess you are right by stating that the mqtt service didn’t exit fine although it was reported as exited in balena dashboard.

Thanks a lot.  
Jan.

---

<div class="post-metadata">

**Author:** ![roman-mazur](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/roman-mazur/32/2194_2.png) [@roman-mazur](https://forums.balena.io/u/roman-mazur)\
**Post date:** [October 3, 2019, 3:10pm UTC](https://forums.balena.io/t/balenaos-is-listening-to-mqtt-port-1883/35328/5 "2019-10-03T15:10:20Z")

</div>

@janvda Did you have a chance to check `balena ps` output. I wonder if the container was still running as reported by the engine. In such a case, and if you have seen the dashboard reporting it as stopped, there must be some issue with the supervisor…

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/janvda/32/1271_2.png) [@janvda](https://forums.balena.io/u/janvda)\
**Post date:** [October 3, 2019, 3:14pm UTC](https://forums.balena.io/t/balenaos-is-listening-to-mqtt-port-1883/35328/6 "2019-10-03T15:14:40Z")

</div>

No, I didn’t do that. I saw your message after I rebooted it. If it reappears I will share the `balena ps` output.

---

<div class="post-metadata">

**Author:** ![roman-mazur](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/roman-mazur/32/2194_2.png) [@roman-mazur](https://forums.balena.io/u/roman-mazur)\
**Post date:** [October 3, 2019, 3:16pm UTC](https://forums.balena.io/t/balenaos-is-listening-to-mqtt-port-1883/35328/7 "2019-10-03T15:16:57Z")

</div>

Thanks. Let us know.

---

<div class="post-metadata">

**Author:** ![valerian](https://avatars.discourse-cdn.com/v4/letter/v/977dab/32.png) [@valerian](https://forums.balena.io/u/valerian)\
**Post date:** [August 8, 2024, 1:43pm UTC](https://forums.balena.io/t/balenaos-is-listening-to-mqtt-port-1883/35328/9 "2024-08-08T13:43:59Z")

</div>

I am having the same issue, however rebooting the device does not fix it  
Output of `balena ps -a` is:

```auto
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0a97df3ce379 f08ae9919451 "/docker-entrypoint.…" 4 minutes ago Up 2 minutes 0.0.0.0:1883->1883/tcp, :::1883->1883/tcp mqtt-broker_9385585_3116360_7912cd0986ba580605c318c1e581a372
0fb42db7631e a121ba1af9a7 "/usr/bin/entry.sh .…" 40 minutes ago Up 2 minutes mqtt-sub_9385587_3116360_7912cd0986ba580605c318c1e581a372
31b3d9621696 8d41e6cfd5e5 "/usr/bin/entry.sh .…" 40 minutes ago Up 2 minutes mqtt-pub_9385586_3116360_7912cd0986ba580605c318c1e581a372

```
