Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unable to open log file /mosquitto/log/mosquitto.log for writing. #28

Open
cpfowler opened this issue Aug 4, 2022 · 5 comments

Comments

@cpfowler
Copy link

cpfowler commented Aug 4, 2022

Fixed the passwd permissions problem: #27

Now I have what seems to be the exact same problem, but for the log file:
1659577565: Loading config file /mosquitto/config/mosquitto-unraid-default.conf
1659577565: Error: Unable to open log file /mosquitto/log/mosquitto.log for writing.
1659577715: Error: Permission denied.

I tried creating the logfile myself, then setting the permissions for it.
Ran the same 2 commands from Unraid webGUI terminal (which fixed passwd problem):
chown -R 99:100 /mnt/user/appdata/mosquitto
chmod -R 775 /mnt/user/appdata/mosquitto

@cmccambridge
Copy link
Owner

@cpfowler Could you share how you have configured mosquitto-unraid?

e.g.:

  • Your docker command line after saving the configuration
  • Any specific customizations you may have made?
  • In particular, have you provided a mount path for the Log Directory?
  • Or, have you customized the user configuration option?

@cpfowler
Copy link
Author

cpfowler commented Aug 7, 2022

I was able to fix this with more permission changes.
I looked through the docker image layers, and found where you create the user and group 1883:1883

So in Unraid's webGUI terminal, I used chown -R 1883:1883 and chmod -R 775 on Mosquitto's appdata folder.
After that, no more permission errors for passwd file, and /logs.

I THINK the problem is this Unraid specific docker image isn't setting folder permissions/owner correctly when they're created; such as /appdata/mosquitto/; /appdata/mosquitto/logs/; and /appdata/mosquitto/passwd when using "mosquitto_passwd."
Without doing any customizations nor changes to the default Unraid Docker template, other than setting an IP address, it gave me 2 permissions errors I had to fix.

Here's the info requested:
root@localhost:# /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker run -d --name='Mosquitto' --net='br0.2' --ip='192.168.2.22' -e TZ="America/Chicago" -e HOST_OS="Unraid" -e HOST_HOSTNAME="Tower" -e HOST_CONTAINERNAME="Mosquitto" -e 'RUN_INSECURE_MQTT_SERVER'='0' -e 'TCP_PORT_1883'='1883' -e 'TCP_PORT_8883'='' -e 'TCP_PORT_9001'='9001' -l net.unraid.docker.managed=dockerman -l net.unraid.docker.icon='https://raw.githubusercontent.com/cmccambridge/mosquitto-unraid/master/media/eclipse-mosquitto.png' -v '/mnt/user/appdata/mosquitto':'/mosquitto/config':'rw' -v '/mnt/user/appdata/mosquitto/data':'/mosquitto/data':'rw' -v '/mnt/user/appdata/mosquitto/log':'/mosquitto/log':'rw' 'cmccambridge/mosquitto-unraid:latest'
19943c6e0dbe9f5dfb1fd451f3362794c9773e4507609efc2d7a7f35a2511ebe

Only customizations I made to the docker template was changing network to my br0.2 and giving it an internal IP.

I mounted /mnt/user/appdata/mosquitto/logs/ for the log directory.

I didn't add any extra options for the user, PUID, PGID, nor UMASK.

mosquitto_unraid_template

@xm4rcell0x
Copy link

Error: Unable to open log file /mosquitto/log/mosquitto.log for writing.
I had the same problem.
chown -R 1883:1883 /mnt/user/appdata/mosquitto
and
chmod -R 775 /mnt/user/appdata/mosquitto
solved my problem. Thanks!

@chadblose
Copy link

I have tried the above permission change suggestions but I'm still getting errors unable to read the file. Inside the container the user and group are both mosquitto with permissions -rwxrwxr-x. In Unraid, 1883 is the group and user.

@nerdosity
Copy link

This is still happening. I had to reset the permissions like @xm4rcell0x suggested, and it worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants