mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

Error: Address already in use

Open Ianszh opened this issue 4 years ago • 6 comments

Just updated to 2.0.9 though DietPi sys and now have an error and can no longer connect

1616235035: mosquitto version 2.0.9 starting 1616235035: Using default config. 1616235035: Starting in local only mode. Connections will only be possible from clients running on this machine. 1616235035: Create a configuration file which defines a listener to allow remote access. 1616235035: Opening ipv4 listen socket on port 1883. 1616235035: Error: Address already in use 1616235035: Opening ipv6 listen socket on port 1883. 1616235035: Error: Address already in use

Ianszh avatar Mar 20 '21 10:03 Ianszh

It looks as though something else is already listening on port 1883. Can you confirm whether that is the case?

ralight avatar Mar 20 '21 10:03 ralight

Note also the line Starting in local only mode. Connections will only be possible from clients running on this machine. - see https://mosquitto.org/documentation/authentication-methods/

ralight avatar Mar 20 '21 10:03 ralight

Thanks, it was running fine before the update

this is my grep LISTEN

tcp LISTEN 0 100 127.0.0.1:26002 : users:(("nxnode.bin",pid=1281,fd=7)) tcp LISTEN 0 128 :22 : users:(("dropbear",pid=624,fd=3)) tcp LISTEN 0 128 :1880 : users:(("node-red",pid=5345,fd=21)) tcp LISTEN 0 128 127.0.0.1:8088 : users:(("influxd",pid=5354,fd=3)) tcp LISTEN 0 128 127.0.0.1:7002 : users:(("nxnode.bin",pid=1281,fd=19)) tcp LISTEN 0 100 127.0.0.1:1883 : users:(("mosquitto",pid=5337,fd=5)) tcp LISTEN 0 50 :445 : users:(("smbd",pid=5313,fd=32)) tcp LISTEN 0 100 :4000 : users:(("nxd",pid=807,fd=3)) tcp LISTEN 0 100 127.0.0.1:21024 : users:(("nxserver.bin",pid=481,fd=8)) tcp LISTEN 0 100 127.0.0.1:12002 : users:(("nxnode.bin",pid=1281,fd=16)) tcp LISTEN 0 100 127.0.0.1:25002 : users:(("nxclient.bin",pid=1318,fd=7)) tcp LISTEN 0 50 :139 : users:(("smbd",pid=5313,fd=33)) tcp LISTEN 0 32 :::21 ::: users:(("proftpd",pid=5292,fd=0)) tcp LISTEN 0 128 :::8086 ::: users:(("influxd",pid=5354,fd=306)) tcp LISTEN 0 128 :::22 ::: users:(("dropbear",pid=624,fd=4)) tcp LISTEN 0 128 :::3001 ::: users:(("grafana-server",pid=5362,fd=12)) tcp LISTEN 0 128 ::1:7002 ::: users:(("nxnode.bin",pid=1281,fd=17)) tcp LISTEN 0 100 ::1:1883 :::* users:(("mosquitto",pid=5337,fd=6)) tcp LISTEN 0 50 :::445 :::* users:(("smbd",pid=5313,fd=30)) tcp LISTEN 0 100 :::4000 :::* users:(("nxd",pid=807,fd=4)) tcp LISTEN 0 50 :::139 :::* users

Ianszh avatar Mar 20 '21 10:03 Ianszh

tcp LISTEN 0 100 127.0.0.1:1883 : users:(("mosquitto",pid=5337,fd=5)) - it looks like Mosquitto is already running.

ralight avatar Mar 20 '21 14:03 ralight

It sounds like you might be trying to start Mosquitto twice, the first time is a leftover from earlier versions that need deletion. The words below are from a post in another thread.

There was a root CRON job that runs launcher.sh which contained sudo mosquitto -d

How did I find it. Well once I found CRON has a @reboot option I looked further and found CRON is by user including root. So I winged it and tried sudo crontab -l hoping the use of sudo finds root cronjobs instead of pi user jobs and there as a another job.

After that it was a tidy up of all the other things I had tweaked and re-enable the systemd job on reboot. sudo systemctl enable mosquitto.service

So now have 2.0.11 working as I like. I suspect that CRON job was a left over from earlier versions of Mosquitto (I was on 1.5 or 1.6) but the update to 2.0.11 didn't delete it when it created the mosquitto.service job.

WombatHollow avatar Jun 11 '21 02:06 WombatHollow

I have just got a fresh RPi image then tried to install Mosquitto. After the install I ran mosquitto -v and got this the same error. which makes me think it isn't running twice 1662518134: mosquitto version 2.0.11 starting 1662518134: Using default config. 1662518134: Starting in local only mode. Connections will only be possible from clients running on this machine. 1662518134: Create a configuration file which defines a listener to allow remote access. 1662518134: For more details see https://mosquitto.org/documentation/authentication-methods/ 1662518134: Opening ipv4 listen socket on port 1883. 1662518134: Error: Address already in use 1662518134: Opening ipv6 listen socket on port 1883. 1662518134: Error: Address already in use

maddogeco avatar Sep 07 '22 02:09 maddogeco

I get the same issue

1679611138: mosquitto version 2.0.11 starting 1679611138: Using default config. 1679611138: Starting in local only mode. Connections will only be possible from clients running on this machine. 1679611138: Create a configuration file which defines a listener to allow remote access. 1679611138: For more details see https://mosquitto.org/documentation/authentication-methods/ 1679611138: Opening ipv4 listen socket on port 1883. 1679611138: Error: Address already in use 1679611138: Opening ipv6 listen socket on port 1883. 1679611138: Error: Address already in use

I created a connect.conf file in which I defined the listener to 1883 and set the allow_anonymous to true but still get the local mode. any idea why?

tomlas32 avatar Mar 23 '23 22:03 tomlas32

See the debian bug #892491. I think it is describing the same issue.

narc-Ontakac2 avatar Aug 19 '23 11:08 narc-Ontakac2

This may have been fixed in between by modifications in systemd restart behavior. Is anybody still seeing this?

narc-Ontakac2 avatar Aug 19 '23 11:08 narc-Ontakac2