[SOLVED] Mqtt broker not working probably: Error: Address already in use

I have a complete new installation on a Raspberry Pi 3b, where i have only Raspbian 4.14 and mosquito + mosquito-clinets. I upgraded after I got the error to mosquitto 1.5.3. But this did not solve my problem. Upgrade to mosquitto 1.5

I have for each task in my smarthome one Raspberry Pi 3b:

  1. openhab2 with Openhabian
  2. influxdb with Raspbian
  3. grafana with Raspbian
  4. mqtt with Raspbian

OS: Raspian

pi@mqtt:~ $ uname -a
Linux mqtt 4.14.70-v7+ #1144 SMP Tue Sep 18 17:34:46 BST 2018 armv7l GNU/Linux

HW:

pi@mqtt:~ $ cat /proc/device-tree/model
Raspberry Pi 3 Model B Rev 1.2

My Error:

pi@mqtt:~ $ mosquitto -v
1539077460: mosquitto version 1.5.3 starting
1539077460: Using default config.
1539077460: Opening ipv4 listen socket on port 1883.
1539077460: Error: Address already in use

Mosquitto Config:

pi@mqtt:~ $ ls /etc/mosquitto/
ca_certificates  certs  conf.d  mosquitto.conf

pi@mqtt:~ $ ls /etc/mosquitto/conf.d/
README

pi@mqtt:~ $ cat /etc/mosquitto/mosquitto.conf
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

That doesn’t make sense, you 2 OS on your raspberry?
Is it OpenHABian or Rasbian? You can’t have both

He has more than one Raspberry !!!

netstat -anp | grep 1883 , what does it say? if you get a result, try killing the process, kill -9 , then restart mosquitto.

1 Like

Ok, I got mislead by the grammar a bit.
I guess:

  • Remove mosquitto.
  • Scan the port on that pi to check if another process is using it (unlikely if that the only app running on that machine).
  • Install mosquitto again
pi@raspberrypi:~ $ netstat -anp | grep 1883
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 0.0.0.0:1883            0.0.0.0:*               LISTEN      -
tcp6       0      0 :::1883                 :::*                    LISTEN      -

After installing 1.5.3 Error in poll was gone

1539079649: Error in poll: Interrupted system call.

log:

pi@raspberrypi:~ $ cat /var/log/mosquitto/mosquitto.log
1539079636: mosquitto version 1.4.10 (build date Fri, 22 Dec 2017 08:19:25 +0000) starting
1539079636: Config loaded from /etc/mosquitto/mosquitto.conf.
1539079636: Opening ipv4 listen socket on port 1883.
1539079636: Opening ipv6 listen socket on port 1883.
1539079649: Error in poll: Interrupted system call.
1539079649: mosquitto version 1.4.10 terminating
1539079654: mosquitto version 1.4.10 (build date Fri, 22 Dec 2017 08:19:25 +0000) starting
1539079654: Config loaded from /etc/mosquitto/mosquitto.conf.
1539079654: Opening ipv4 listen socket on port 1883.
1539079654: Opening ipv6 listen socket on port 1883.
1539081462: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1539081987: New connection from 192.168.178.70 on port 1883.
1539081987: New client connected from 192.168.178.70 as MQTT_FX_Client (c1, k60).
1539083263: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
1539083657: Error in poll: Interrupted system call.
1539083657: mosquitto version 1.4.10 terminating
1539083657: mosquitto version 1.5.3 starting
1539083657: Config loaded from /etc/mosquitto/mosquitto.conf.
1539083657: Opening ipv4 listen socket on port 1883.
1539083657: Opening ipv6 listen socket on port 1883.
1539083700: mosquitto version 1.5.3 terminating
1539083704: mosquitto version 1.5.3 starting

Looks like it’s working
Please mark the thread as solved

I killed the mosquitto process and without reboot or restarting the process:

pi@raspberrypi:~ $ mosquitto -v
1539084842: mosquitto version 1.5.3 starting
1539084842: Using default config.
1539084842: Opening ipv4 listen socket on port 1883.
1539084842: Opening ipv6 listen socket on port 1883.

No Error. But after reboot i get the same error again.

pi@raspberrypi:~ $ mosquitto -v
1539084974: mosquitto version 1.5.3 starting
1539084974: Using default config.
1539084974: Opening ipv4 listen socket on port 1883.
1539084974: Error: Address already in use

Hm, are you trying to start the mosquitto process manually each time? You’re not supposed to, the mosquitto service starts by itself on boot (daemonizing).

The correct way to stop/start the mosquitto service is by:

service mosquitto status   ; gets currents status
service mosquitto stop
service mosquitto start
1 Like

Thanks alot for your help, this is maybe my tenth setup.

At this point I did not stop, start, restart the service manualy, neither bey service nor by systemctl
after changing something i always performed a reboot.

  1. installing Raspian
  2. installing mosquitto
  3. installing mosquitto-clinets
  4. mosquitto -v : ERROR
  5. reboot
  6. mosquitto -v : ERROR
  7. killing mosquitto process NO ERROR
  8. reboot
    9.mosquitto -v : ERROR

Before kiling mosquitto prozess, what is the output of

sudo service mosquitto status
1 Like
pi@raspberrypi:~ $ sudo service mosquitto status
â—Ź mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
   Active: active (running) since Tue 2018-10-09 11:49:13 UTC; 18min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 327 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCC
   CGroup: /system.slice/mosquitto.service
           └─388 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Oct 09 11:49:13 raspberrypi systemd[1]: Starting LSB: mosquitto MQTT v3.1 messag
Oct 09 11:49:13 raspberrypi mosquitto[327]: Starting network daemon:: mosquitto.
Oct 09 11:49:13 raspberrypi systemd[1]: Started LSB: mosquitto MQTT v3.1 message

i get the same error on Openhabian:

[14:23:27] openhabian@openHABianPi:~$ mosquitto -v
1539087812: mosquitto version 1.4.10 (build date Fri, 22 Dec 2017 08:19:25 +0000) starting
1539087812: Using default config.
1539087812: Opening ipv4 listen socket on port 1883.
1539087812: Error: Address already in use

Your output of

sudo service mosquitto status

clearly says that it is running after boot, so by issueing

mosquitto -v

you try to start it a second time, which is not possible.

oh man, i did not know that, i wanted to “watch” the mosquitto service while running.

Hii hmerk,

What is the problem in my case ?
can you please help me ?

Thanks

How shall I know ??
Check your mosquitto log if there is any

see this

You already have a service using port 1883
Change it
Or change the mosquitto port(not recommended)

1 Like