Sync error on new profile on Android client only: Permission denied to create directory

Operating system

Android

Joplin version

3.2.7

Sync target

WebDAV

What issue do you have?

I have created a new user on my Nextcloud, which I am using via WebDAV successfully to synchronize another profile already.

I created a new profile in my Windows desktop client, and successfully synchronized the new profile to the new Nextcloud user.

Then I created the profile in my Android client, but synchronizing gives this error immediately:

Last error: Error: MKCOL locks/: Permission denied to create directory (Exception Sabre\DAV\Exception\Forbidden) (403)

And then a bunch of XML that just repeats the error message.

Looking for more information, I set up the profile on my Ubuntu laptop client as well, and it was also able to successfully sync the new profile to the new Nextcloud user.

I'm self-hosting on a DigitalOcean droplet that is admittedly a bit out of date. But the sync works fine on all my machines, only Android gives this error. Here's some output from my Apache logs comparing the successful desktop sync to the failed mobile sync attempts:

changelog [18/Apr/2025:04:48:10 +0000] "GET /remote.php/dav/files/changelog/info.json HTTP/1.1" 200 2191 "-" "Joplin/1.0"

changelog [18/Apr/2025:04:48:28 +0000] "GET /remote.php/dav/files/changelog/info.json HTTP/1.1" 404 4621 "-" "Joplin/1.0"

For some reason, the desktop clients get 200s and 207s and the mobile client is getting 404s and 403s.

However, the mobile client is still able to sync my usual profile successfully!

So the problem is ONLY with the new profile and ONLY on the Android client.

I only found one other instance of this exact error message in the history of the forum or issues, here: Error

But they never resolved their problem. Someone had a similar issue on a different hosting setup here: WebDav sync failed with Joplin - Runbox Chat - Runbox Community Forum

I'm not filing a bug report yet because I'm not sure if it's a bug with Joplin or just a bug with my old version of Nextcloud. I'll update everything if I absolutely have to, but I'd really prefer to avoid the inconvenience if there's a quicker fix.

Anybody seen this one before or have any speculation as to what might be going on? I'm not seeing any other relevant errors in my system logs or the Nextcloud admin log.

Bump. I've found some more examples of this strange issue, including several closed issues:

I seem to have a unique opportunity to figure out this issue once and for all, because it's not intermittent: It's happening 100% of the time on my Android client and 0% of the time elsewhere.

But I'm really not sure where to look next. Any ideas appreciated.

Hey folks, would love some support on this. Should I open another bug report even though the other ones were closed?

The error message has an XML payload with an xmlns attribute pointing to sabredav.org

This doesn't seem like a Joplin bug, but Joplin must be involved somehow because, again, this profile with the exact same settings works fine on Windows, OS X, and Linux.

My hunch is that the mobile client handles DAV authentication differently somehow. What I don't understand is where it's trying to create a directory and be denied permission. If it's trying to make a new folder locally on the Android device, then why is there a DAV service url in the error? If it's trying to create a new folder remotely on my Nextcloud server, why? I'm just syncing, so it shouldn't need to write anything to the remote server at all.

Astounding... the error seems to have resolved itself after a few days. That's a pisser, isn't it?

Oh, great...

Now I'm getting this error on my main profile... the mission critical one.

I really don't want to go five days without syncing to my phone. It's an accessibility issue at this point.

Now what...

Ok.

New theory:

This is specifically a multiple profiles problem.

I searched the Joplin source code repo for instances of the phrase "sabre", and found no results. That means Sabre must be Nextcloud's DAV server.

Maybe one profile is establishing a lock on the server, and permission is denied to the other profile.

The issue goes away intermittently because lock files are probably purged sometimes.

So, the root cause could be in my Nextcloud server.

At least I have a direction for tomorrow now!

I think you are probably right with this analysis. Some of the other sync targets like Dropbox and OneDrive only support one profile, but in the case of WebDAV / NextCloud you can select the path on the server, so should be able to support multiple profiles on one account. But the provider itself may have some limitations which could cause issues with this

Thanks, I wonder if it is a combination of mobile + multi-profile issue which perhaps is why it's a relatively rare problem. Because, I have not seen this error on any desktop client ever, yet I've had it happen to both profiles on Android now. I'm not familiar enough with the Joplin codebase to know if DAV support is different on mobile, but I'm kind of assuming it is at this point. It's a busy week, so not sure if I'll be able to confirm my suspicions soon.

I don't think the mobile implementation is any different to desktop. The relevant files in the source code I believe are:
packages/lib/WebDavApi.js
packages/lib/file-api-driver-webdav.js

As your webdav provider is a Nextcloud, have you tried setting the sync target to be nextcloud instead of webdav in the Joplin mobile client? Maybe that might help?

After searching the error on google I came across this, see if this helps too:

"The part that was missing on all posts and documentation I found was to add "www-data" group to have Read/Write permission on the WebDAV shared folder."

Also I found this, which also is a reported issue for a similar error only when using WebDAV via Android:

It may well be that there is something different about a common or native implementation of a WebDAV client on Android (so not specific to Joplin code), which maybe requires additional permission to work correctly

Another potential solution here:

"In the Nextcloud External Storage setting, you have to enable "show hidden files".
Then sync each Joplin instance.
After syncing each instance, you can disable "show hidden files" and it still syncs fine."

And also:

"I just had the ā€œ403 forbiddenā€ mkcol today and this helped me a lot! I logged on the nextcloud directory, under nextcloud>user>files>desired directory and changed the owner of the directory to ā€œwww-dataā€ by using "chown -R www-data:www-data /path/to/desired/directory"

Also, I notice in your OP that you mentioned you created a new user which you synced another profile with. What happens if you use the same user for which you originally created the profile for which you are trying to sync?

Thanks so much for looking into this with me!

The www-data user already owns all of my Nextcloud paths, so unfortunately I'll have to keep looking for a fix. I think you're on to something with it being Android-specific.

Also how old is your Nextcloud version? For very old versions, there may be issues due to bugs in NextCloud. I recall reading a thread from several years ago where folders can become locked if a transfer is interrupted or renamed while transferring. Also some reported issues of there being locks just after upgrading Nextcloud.

I saw some mention of there being a file locking setting in Nextcloud which you can disable. So worth checking if there is such a feature available on your instance and seeing whether it is enabled or not

Making a closer analysis to your specific error message in the OP, I had a think about what each part actually means:

  1. MKCOL: This is a type of HTTP request method for WebDAV
  2. locks/: This is a folder created as part of the Joplin data folder structure
  3. (Exception Sabre\DAV\Exception\Forbidden) (403): Response from the WebDAV server, in your case this is a NextCloud server
  4. Permission denied to create directory: This is the actual issue, a permission issue. Regardless of how/why this only happens on Android, this is what needs to be dealt with somehow

So file locking in NextCloud must be a red herring, the concept of 'lock' here is a Joplin concept, nothing to do with the server. So a more suitable google search to target your specific problem with WebDAV would be:
mkcol "permission denied to create directory"

This is the second hit Create a folder for another user - ā„¹ļø Support - Nextcloud community , which says a NextCloud user can only create his/her own folders. So there are a couple of things you can try:

  1. Change the folder containing the data for the particular profile, to be owned by the NextCloud user that will access that profile (and always use the same user), rather than the www-data user
  2. Assuming the locks folder does not exist, create it manually at the relevant path on NextCloud. If the sync then complains about another folder, create that one too and so on. If then you start getting permission errors for creating / updating files rather than directories (and all directories have the correct owner and read/write/list access set) then this would not provide a solution

I won't lie, my Nextcloud instance is pretty old and has been telling me to update for quite some time. At this point, it seems like that's the most likely thing that could resolve this, so I'm gonna bite the bullet and upgrade. I'll report back if things are fixed.

I did spend quite a long time fiddling with permissions and lock files on my server filesystem, but nothing seemed to make a difference. I even went so far as to go into the root Nextcloud folder and recursively delete all locks/ directories. And, as far as I know, I don't have any Nextcloud users on the OS itself, just www-data.

If you only have the www-data user, what did you mean by this in your original post?

And are you logging in using the www-data user as the user for connecting to WebDAV which you enter in the Joplin sync screen?

Ok, I've finished migrating to a fresh install of Nextcloud on Ubuntu 22 LTS installed via snap. This approach seems to require having all files owned by root as NC itself runs as a system service.

Unfortunately, it didn't make one bit of difference to my issue. I still get an error on MKCOL locks/ when syncing a profile after switching.

Back to square one, I guess. I'm still not even sure if this is an Android bug, a Joplin bug, a Nextcloud bug, or some combination of the three.

I still don't understand what you were referring to when you said you created a new user on Nextcloud, how that relates to the connection details you use to connect sync in Joplin, and whether or not that has any significance

Ah, thanks for the reminder. Nextcloud has its own user table in its database. So I've been creating new users through the Nextcloud admin interface, but they're all still running on the machine with the same Linux user.

Previously I was running with www-data, but when I migrated, the instructions said to leave everything as owned by root, so that's what I've done this time around.

When entering sync credentials in Joplin, I have to enter the Nextcloud username and password. This has always worked for me, and it still works, except for this lock file conflict problem.

1 Like

Did you attempt creating the directory on Nexcloud which the Joplin sync complained it could not create, and after doing so, did the sync progress onto a different error / an error for a different directory it could not create?