mosquitto
mosquitto copied to clipboard
Can't start mosquitto.service
hi, installed with the apt-get install method.
Can't autostart so I ran sudo systemctl start mosquitto.service
and then sudo systemctl status mosquitto.service
and this is the output:
Loaded: loaded (/etc/systemd/system/mosquitto.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Tue 2020-02-18 18:54:47 WET; 4s ago Docs: man:mosquitto.conf(5) man:mosquitto(8) Process: 1949 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE) Main PID: 1949 (code=exited, status=1/FAILURE)
Feb 18 18:54:47 raspberrypi systemd[1]: mosquitto.service: Service RestartSec=100ms expired, scheduling restart. Feb 18 18:54:47 raspberrypi systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5. Feb 18 18:54:47 raspberrypi systemd[1]: Stopped Mosquitto MQTT v3.1/v3.1.1 Broker. Feb 18 18:54:47 raspberrypi systemd[1]: mosquitto.service: Start request repeated too quickly. Feb 18 18:54:47 raspberrypi systemd[1]: mosquitto.service: Failed with result 'exit-code'. Feb 18 18:54:47 raspberrypi systemd[1]: Failed to start Mosquitto MQTT v3.1/v3.1.1 Broker.
so i executed /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
and it outputed:
1582051833: mosquitto version 1.5.7 starting 1582051833: Config loaded from /etc/mosquitto/mosquitto.conf. 1582051833: Error: Unable to open pwfile "/etc/mosquitto/passwd ". 1582051833: Error opening password file "/etc/mosquitto/passwd ".
it seems to be a permissions problem, tried some things but can't get it to work. Can anybody help pls?
Try doing sudo /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
instead - I doubt your user would (or should) have access to /etc/mosquitto/passwd
. Hopefully that will tell you why it is failing.
Hi, I have the same problem on openSuse, my user is root:
vmi:/etc/mosquitto # service mosquitto status
● mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
Loaded: loaded (/usr/lib/systemd/system/mosquitto.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2020-09-16 09:22:43 CEST; 7min ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 1676 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE)
Main PID: 1676 (code=exited, status=1/FAILURE)
Sep 16 09:22:43 vmi436410 systemd[1]: Started Mosquitto MQTT v3.1/v3.1.1 Broker.
Sep 16 09:22:43 vmi436410 mosquitto[1676]: 1600240963: Loading config file /etc/mosquitto/conf.d/TLSconfig.conf
Sep 16 09:22:43 vmi436410 mosquitto[1676]: mosquitto version 1.6.12 starting
Sep 16 09:22:43 vmi436410 mosquitto[1676]: Config loaded from /etc/mosquitto/mosquitto.conf.
Sep 16 09:22:43 vmi436410 mosquitto[1676]: Error: Unable to open pwfile "/etc/mosquitto/passwd".
Sep 16 09:22:43 vmi436410 mosquitto[1676]: Error opening password file "/etc/mosquitto/passwd".
Sep 16 09:22:43 vmi436410 systemd[1]: mosquitto.service: Main process exited, code=exited, status=1/FAILURE
Sep 16 09:22:43 vmi436410 systemd[1]: mosquitto.service: Unit entered failed state.
Sep 16 09:22:43 vmi436410 systemd[1]: mosquitto.service: Failed with result 'exit-code'.
vmi:/etc/mosquitto #
for a few weeks it worked and since yesterday it no longer works.
Dear people, i am a newbee and im proud to got the instal on mij raspberri pi. (domnoticz works fine)
A have a mqtt stick, it works fine i think, i can ad and a see the zigbee sensor but than... Nothing, got a tip i should test if the server is running, It dit not, so thats the problem. I found in ssh the error, but i have no clou..
Hope you know what i could do.. Best regards Karel
● mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Wed 2020-12-30 21:47:33 CET; 1min 15s ago Docs: man:mosquitto.conf(5) man:mosquitto(8) Process: 504 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf (code=exited, status=1/FAILURE) Main PID: 504 (code=exited, status=1/FAILURE)
dec 30 21:47:33 raspberrypi systemd[1]: mosquitto.service: Service RestartSec=100ms expired, scheduling restart. dec 30 21:47:33 raspberrypi systemd[1]: mosquitto.service: Scheduled restart job, restart counter is at 5. dec 30 21:47:33 raspberrypi systemd[1]: Stopped Mosquitto MQTT v3.1/v3.1.1 Broker. dec 30 21:47:33 raspberrypi systemd[1]: mosquitto.service: Start request repeated too quickly. dec 30 21:47:33 raspberrypi systemd[1]: mosquitto.service: Failed with result 'exit-code'. dec 30 21:47:33 raspberrypi systemd[1]: Failed to start Mosquitto MQTT v3.1/v3.1.1 Broker.
In my case the issue is that the log file at /var/log/mosquitto/mosquitto.log is corrupt. This is the first time I've seen a corrupt file on a GNU/Linux system.
$ ls -la /var/log/mosquitto/
ls: cannot access '/var/log/mosquitto/mosquitto.log': No such file or directory
total 40
drwxr-xr-x 2 root root 4096 Feb 3 00:00 .
drwxr-xr-x 1 root root 4096 Feb 5 00:00 ..
c????????? ? ? ? ? ? mosquitto.log
-rw-rw-rw- 1 root root 27127 Feb 3 00:00 mosquitto.log.1.gz
I did have a power outage a couple of days ago but the system came back online without a hitch, it was only after a proper system shutdown last night that mosquitto wouldn't start. No idea whether this is a mosquitto issue or a system issue, everything else seems unaffected though.
@lost-RD wow, that looks like filesystem corruption to me - I'd make sure you've got your data off there.
Everybody else - my comment about running sudo /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
to get more information still stands.
Wrote an empty file to the file address and chmod 666 and mosquitto is back up and running, I'll take that advice and backup.
@lost-RD I had a similar file corruption happen recently to my mosquitto log file too. I'm working in a multi-tenant environment, so I do not have the permissions to remove the corrupted file myself. I'm using the most recent docker image as of 2/19/2021
On further reading you can get this sort of effect if the stat()
call fails. The stat man page lists these reasons for possible failure:
- EACCES - Search permission is denied for one of the directories in the path prefix of pathname. For @lost-RD the permissions we can see look correct, and if it was a permission problem the other file would have been affected.
- EBADF - fd is not a valid open file descriptor. Unlikely to be the problem.
- EFAULT Bad address. Highly unlikely in
ls
- ELOOP Too many symbolic links encountered while traversing the path. Would have affected the other files.
- ENAMETOOLONG pathname is too long. Would have affected the other files.
- ENOENT A component of pathname does not exist or is a dangling symbolic link. Would have affected the other files.
- ENOMEM Out of memory (i.e., kernel memory). Unlikely
- ENOTDIR A component of the path prefix of pathname is not a directory. Couldn't happen here
- EOVERFLOW pathname or fd refers to a file whose size, inode number, or number of blocks cannot be represented in, respectively, the types off_t, ino_t, or blkcnt_t. This error can occur when, for example, an application compiled on a 32-bit platform without -D_FILE_OFFSET_BITS=64 calls stat() on a file whose size exceeds (1<<31)-1 bytes. The file size could potentially be a problem, but I doubt that you're on a 32-bit system so that won't apply.
In conclusion - I'm not much the wiser as to what could have caused it, or why it's showing as it is.
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.
I had the same issue after typing the command sudo /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
got
1624240992: Loading config file /etc/mosquitto/conf.d/bk_default.conf
1624240992: Loading config file /etc/mosquitto/conf.d/custom.conf
1624240992: Error: Duplicate password_file value in configuration.
1624240992: Error found at /etc/mosquitto/conf.d/custom.conf:2.
1624240992: Error found at /etc/mosquitto/mosquitto.conf:11.
I found out I had multiple config files, so I removed the old ones.
Hope it helps!
: mosquitto.service: Scheduled restart job, restart counter is at 5. : Stopped Mosquitto MQTT Broker. : mosquitto.service: Start request repeated too quickly. : mosquitto.service: Failed with result 'exit-code'. : Failed to start Mosquitto MQTT Broker.
When I checked service logs via
journalctl -u mosquitto.service
It pointed out default configuration file line 11 where it includes custom configurations directory. Then I noticed a whitespace at the end of the line
include_dir /etc/mosquitto/conf.d
I removed the whitespace character and saved the file. It's all OK now.
I have a similar problem
sudo systemctl start mosquitto.service Failed to start mosquitto.service: Unit mosquitto.service not found.
I have run into this problem after making configured SSL for a droplet server running on NGINX. Configurations I have for mymain domain:
server{
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.ge/fullchain.pem; # managed by>
ssl_certificate_key /etc/letsencrypt/live/example.ge/privkey.pem; # managed >
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
server_name example.ge www.example.ge;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# location /overview {
# proxy_pass http://127.0.0.1:3000$request_uri;
# proxy_redirect off;
# }
}
}
server {
if ($host = mtkvaripay.ge) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = www.mtkvaripay.ge) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name example.ge www.example.ge;
return 404; # managed by Certbot
}
the idea was to add sumdomain mqtt.example.ge
and have secured SSL there too. so I followed an outdated the only existing tutorial on Digital Ocean for the purpose How to Install and Secure the Mosquitto MQTT Messaging Broker on Ubuntu 18.04
Here are /etc/mosquitto/conf.d/default.conf
configs:
allow_anonymous false
password_file /etc/mosquitto/passwd
listener 1883 localhost
listener 8883
certfile /etc/letsencrypt/live/mqtt.example.ge/cert.pem
cafile /etc/letsencrypt/live/mqtt.example.ge/chain.pem
keyfile /etc/letsencrypt/live/mqtt.example.ge/privkey.pem
listener 8083
protocol websockets
certfile /etc/letsencrypt/live/mqtt.example.ge/cert.pem
cafile /etc/letsencrypt/live/mqtt.example.ge/chain.pem
keyfile /etc/letsencrypt/live/mqtt.example.ge/privkey.pem