Suddenly mqtt 1883 port in use error

Hi

I have hass.io installed on standalone intel nuc running ubuntu desktop. Has been working fine using mqtt hass.io addon broker. Suddenly the mqtt hass.io is no longer working and gives the following error:

1541444743: Opening ipv4 listen socket on port 1883.
1541444743: Error: Address in use

I have not changed anything in my setup, just overnight it decided to stop working.

This is my configuration for mqtt broker addon:

{
  "logins": [
    {
      "username": "mike",
      "password": "xxxxxxxxx"
    }
  ],
  "anonymous": false,
  "customize": {
    "active": true,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "plain": false,
  "plain_websockets": false,
  "ssl": true,
  "ssl_websockets": false
}

and

Container : Host
1883/tcp	 : 1883
1884/tcp	 : 1884
8883/tcp	 : 8883
8884/tcp	 : 8884

This is my configuration.yaml

mqtt:
  broker: 192.168.1.50
  username: !secret mqtt_login
  password: !secret mqtt_password
  discovery: true
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'

If i use ssh and type “lsof -i TCP:1883” i get the following output

root@nuc-server:~#  lsof -i TCP:1883
COMMAND    PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
docker-pr 8885 root    4u  IPv6 24371153      0t0  TCP *:1883 (LISTEN)

.

root@nuc-server:~# docker container ls
CONTAINER ID        IMAGE                                   COMMAND                  CREATED             STATUS              PORTS                                                                NAMES
4c3f3ea34ffd        homeassistant/intel-nuc-homeassistant   "/bin/entry.sh pytho…"   10 minutes ago      Up 10 minutes                                                                            homeassistant
d28fdfdf72ad        homeassistant/amd64-addon-samba         "/run.sh"                12 hours ago        Up 12 hours                                                                              addon_core_samba
f1cc4d09375e        homeassistant/amd64-addon-mosquitto     "/run.sh"                12 hours ago        Up 12 hours         0.0.0.0:1883-1884->1883-1884/tcp, 0.0.0.0:8883-8884->8883-8884/tcp   addon_core_mosquitto
912f0fd86b93        homeassistant/amd64-hassio-supervisor   "python3 -m hassio"      12 hours ago        Up 12 hours                                                                              hassio_supervisor
977951429a76        ottowinter/esphomeyaml-hassio-amd64     "esphomeyaml /config…"   47 hours ago        Up 20 hours         0.0.0.0:6052-6053->6052-6053/tcp                                     addon_7bce6681_esphomeyaml
5c449a89476d        homeassistant/amd64-addon-ssh           "/run.sh"                47 hours ago        Up 20 hours         0.0.0.0:22->22/tcp                                                   addon_core_ssh
af96552f1933        homeassistant/amd64-addon-duckdns       "/run.sh"                47 hours ago        Up 20 hours                                                                              addon_core_duckdns
d1864fafb47d        portainer/portainer                     "/portainer"             4 weeks ago         Up 20 hours         0.0.0.0:9000->9000/tcp                                               portainer

Can anyone tell me what I can do to get it going?

I have tried the following command:

root@nuc-server:~# sudo systemctl stop mosquitto.service
Failed to stop mosquitto.service: Unit mosquitto.service not loaded.
root@nuc-server:~# systemctl status mosquitto.service
Unit mosquitto.service could not be found.

keywords: Mosquitto broker version 3 v 3

ok i have the solution.

step #1 - remove mqtt: and everything under it from configuration.yaml , you don’t want mqtt and you don’t want any of the mqtt config entries in configuration.yaml

step #2 - goto hass.io -> mqtt add on config page. click reset to defaults.

step #3 - restart home assistant

step #4 - goto configuration -> integrations -> mqtt setup -> open the dialog box and setup the mqtt component.

step #5 - restart home assistant again.

2 Likes

Excellence! It works.

Thank you