405 Method Not Allowed when mounting

Trying to mount my NC files using WebDav to my Ubuntu desktop using instructions from Accessing Nextcloud files using WebDAV — Nextcloud latest User Manual latest documentation. Specifically Creating WebDAV mounts on the Linux command line.

  • I installed davfs2.
  • I added the davfs2 group to my user and logged out and back in
  • I created ~/.davfs2
  • I copied /etc/davfs2/secrets (essentially a totally commented out file) to ~/.davfs2/secrets
  • I changed the ownership and perms
  • I added https://<my server name>/nextcloud/remote.php/dav/files/<username>/ <username> <password> to the end of the file It is unclear what $PathToMountPoint $USERNAME $PASSWORD is supposed to be. Is that instead of or in addition to the URL?
Earth:tail -1 ~/.davfs2/davfs2.conf
https://cloud.defariahome.com/nextcloud/remote.php/dav/files/andrew andrew <redacted>
Earth:tail -1 /etc/fstab
https://cloud.defariahome.com/nextcloud/remote.php/dav/files/andrew/ /opt/songbook davfs user,rw,auto 0 0
Earth:sudo mount /opt/songbook
Please enter the username to authenticate with server
https://cloud.defariahome.com/nextcloud/remote.php/dav/files/andrew/ or hit enter for none.
  Username: andrew
Please enter the password to authenticate user andrew with server
https://cloud.defariahome.com/nextcloud/remote.php/dav/files/andrew/ or hit enter for none.
/sbin/mount.davfs: Mounting failed.
405 Method Not Allowed

A Google search of “site:help.nextcloud.com /sbin/mount.davfs: Mounting failed. 405 Method Not Allowed” yields only 2 results, one that says make sure youre’ not blocked by a firewall (I’m not running a firewall) and the other talks about 2MFA and I’m not using that. Also I don’t want to be prompted to enter the username and password - how would that work on a reboot anyway?

Thats wrong. It is the other way around, you should Add yourself to the davfs2 group but I guess you just phrased it wrong :wink:

I could imagine that this is the problem.

This whole procedure, with an entry in /etc/fstab with the option user, copying the system-wide file into the user directory etc., is specifically designed to enable the user himself (i.e. without sudo) to mount the share and to become the owner of that mount.
You’ve put the secrets file in your user directory (probably /home/andrew/.davfs2/secrets) and added yourself to the davfs2 group and then, when you use sudo for the mount process so in fact you change to user root but no information is stored in /root./davfs2/secrets nor is in the system wide file under /etc/davfs2/secrets

So try it without sudo.

I hope this solves your issue!

Much luck,

Sorry, I didn’t mention this. I tried it without sudo and that fails with:

Earth:mount /opt/songbook
/sbin/mount.davfs:/home/andrew/.davfs2/davfs2.conf:77: unknown option

And line 77 is

https://cloud.defariahome.com/nextcloud/remote.php/dav/files/andrew andrew <redacted>

Hmmm… that line doesn’t belong in the davfs2.conf file so I removed it.

I think I might have this. Terrible error messages and documentation. Here’s what I learned.

  • The image above shows the word “nextcloud” in the URL path. This is wrong. I removed it. Having that in there cause confusing error messages like “405 Method not allowed” and “the server does not support WebDAV”
  • The “dav/files/USERNAME” portion is also invalid. Instead, you need to use “webdav”. For example, in my case, this is https://cloud.defariahome.com/remote.php/webdav/SongBook for the SongBook folder at the root of my Nextcloud files.
  • You can use either <URL> <username> <password> or <mountpoint> <username> <password> but 1) the URL needs to be properly formatted as described above and 2) there still needs to be an entry in /etc/fstab that matches. IOW in /etc/fstab you need a line that mentions both the URL and the mount point. I’m using https://cloud.defariahome.com/remote.php/webdav/SongBook /opt/songbook davfs user,rw,auto 0 0. If there is no URL or mountpoint line that contains username and password in ~/.davfs2/secrets then the mount command will prompt for username and password.
  • The mount point must be an existing directory.
  • When you successfully mount a davfs a copy of /etc/davfs2/davfs2.conf will be placed in ~/.davfs2 and apparently otherwise ignored!
  • I got complaints that “the server does not support locks”. Google said to set use_locks to 0 in ~/.davfs2/davfs.conf but that doesn’t work. Has to be in /etc/davfs2/davfs.conf.
  • Once mounted the files appear as owned by your user and group (though under Nextcloud itself they are owned by www-data:www-data).

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