Mosquitto error address already in use

I get an error saying my port is already in use when starting mosquitto

root@OpenHAB:~# mosquitto -v
[393656.339556]~DLT~23300~INFO     ~FIFO /tmp/dlt cannot be opened. Retrying later...
1619595270: mosquitto version 1.6.9 starting
1619595270: Using default config.
1619595270: Opening ipv4 listen socket on port 1883.
1619595270: Error: Address already in use

I configured the port as follows:
lxc config device add OpenHAB myport1883 proxy listen=tcp:0.0.0.0:1883 connect=tcp:127.0.0.1:1883

The port configuration says:

simon@ansi-itx:~$ sudo lsof -i -n | grep 1883
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lsof: no pwd entry for UID 1000000
lxd       3227629         1000000    3u  IPv6 13871533      0t0  TCP *:1883 (LISTEN)
lxd       3227629         1000000    8u  IPv6 13871533      0t0  TCP *:1883 (LISTEN)
simon@ansi-itx:~$ sudo lxc exec OpenHAB -- /bin/bash
root@OpenHAB:~# sudo lsof -i -n | grep 1883
mosquitto  207       mosquitto    7u  IPv4 13249724      0t0  TCP *:1883 (LISTEN)
mosquitto  207       mosquitto    8u  IPv6 13249729      0t0  TCP *:1883 (LISTEN)
mosquitto  207       mosquitto    9u  IPv4 13464490      0t0  TCP 127.0.0.1:1883->127.0.0.1:35182 (ESTABLISHED)
java      6432         openhab  398u  IPv6 13465202      0t0  TCP 127.0.0.1:35182->127.0.0.1:1883 (ESTABLISHED)

I know this it not completely openhab related, but probably someone can help me here.

The errors:

root@OpenHAB:~# tail -f /var/log/mosquitto/mosquitto.log
1619595837: Socket error on client <unknown>, disconnecting.
1619595848: New connection from 127.0.0.1 on port 1883.
1619595848: Socket error on client <unknown>, disconnecting.
1619595848: New connection from 127.0.0.1 on port 1883.
1619595848: Socket error on client <unknown>, disconnecting.
1619595859: New connection from 127.0.0.1 on port 1883.
1619595859: Socket error on client <unknown>, disconnecting.
1619595859: New connection from 127.0.0.1 on port 1883.

This is my mosquitto.conf file

# 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


#the following was added by simon
listener 1883
#persistence true
#persistence_location /var/lib/mosquitto/
persistence_file mosquitto.db
log_dest syslog
log_dest stdout
log_dest topic
log_type error
log_type warning
log_type notice
log_type information
connection_messages true
log_timestamp true
allow_anonymous true
password_file /etc/mosquitto/pwfile

I created a new user with password and used it. Now connection works.

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