Steps to reproduce
Create a share link for a file or folder.
Expected behaviour
A share link should be created. No error message.
Actual behaviour
I get an error message in the browser "Unable to create a link share"
Server configuration
Operating system: Debian Stretch v9.6
Web server: Apache2 v2.4.25-3+deb9u7
Database: MariaDB v10.3.16+maria~stretch
PHP version: v7.3
Nextcloud version: 16.0.2. Actually, I started having this issue just after upgrading from v14 to v15 and it stayed when I upgraded to v16
Updated from an older Nextcloud/ownCloud or fresh install: Nextcloud v15.0.5
List of activated apps:
Enabled:
Nextcloud configuration:
{
"system": {
"updatechecker": false,
"instanceid": "REMOVED SENSITIVE VALUE",
"passwordsalt": "REMOVED SENSITIVE VALUE",
"secret": "REMOVED SENSITIVE VALUE",
"trusted_domains": [
"nextcloud-testenv",
],
"datadirectory": "REMOVED SENSITIVE VALUE",
"overwrite.cli.url": "https:\/\/nextcloud-testenv\/nextcloud",
"overwriteprotocol": "https",
"dbtype": "mysql",
"version": "16.0.2.1",
"dbname": "REMOVED SENSITIVE VALUE",
"dbhost": "REMOVED SENSITIVE VALUE",
"dbtableprefix": "oc_",
"dbuser": "REMOVED SENSITIVE VALUE",
"dbpassword": "REMOVED SENSITIVE VALUE",
"installed": true,
"memcache.local": "\OC\Memcache\APCu",
"memcache.locking": "\OC\Memcache\Redis",
"redis": {
"host": "REMOVED SENSITIVE VALUE",
"port": 6379
},
"loglevel": 0,
"share_folder": "\/externalshares",
"maintenance": false,
"ldapProviderFactory": "\OCA\User_LDAP\LDAPProviderFactory",
"trashbin_retention_obligation": "auto, 7",
"updater.release.channel": "stable",
"twofactor_enforced": "false",
"twofactor_enforced_groups": [],
"twofactor_enforced_excluded_groups": [],
"mysql.utf8mb4": true
},
"apps": {
"accessibility": {
"enabled": "yes",
"installed_version": "1.2.0",
"types": ""
},
"activity": {
"enabled": "yes",
"installed_version": "2.9.1",
"types": "filesystem"
},
"backgroundjob": {
"lastjob": "4540"
},
"bruteforcesettings": {
"enabled": "no",
"installed_version": "1.0.3",
"types": ""
},
"calendar": {
"enabled": "no",
"installed_version": "1.6.4",
"signed": "true",
"types": ""
},
"cloud_federation_api": {
"enabled": "yes",
"installed_version": "0.2.0",
"types": "filesystem"
},
"comments": {
"enabled": "yes",
"installed_version": "1.6.0",
"types": "logging"
},
"configreport": {
"enabled": "no",
"installed_version": "0.1.1",
"types": "filesystem"
},
"contacts": {
"enabled": "yes",
"installed_version": "3.1.3",
"types": ""
},
"core": {
"backgroundjobs_mode": "cron",
"incoming_server2server_share_enabled": "no",
"installed.bundles": "[\"CoreBundle\"]",
"installedat": "1460119461.3085",
"lastcron": "1562358603",
"lastupdateResult": "[]",
"lastupdatedat": "1562351503",
"moveavatarsdone": "yes",
"oc.integritycheck.checker": "[]",
"outgoing_server2server_share_enabled": "no",
"previewsCleanedUp": "1",
"public_documents": "documents\/public.php",
"public_files": "files_sharing\/public.php",
"public_webdav": "dav\/appinfo\/v1\/publicwebdav.php",
"remote_caldav": "dav\/appinfo\/v1\/caldav.php",
"remote_calendar": "dav\/appinfo\/v1\/caldav.php",
"remote_carddav": "dav\/appinfo\/v1\/carddav.php",
"remote_contacts": "dav\/appinfo\/v1\/carddav.php",
"remote_dav": "dav\/appinfo/v2\/remote.php",
"remote_files": "dav\/appinfo\/v1\/webdav.php",
"remote_webdav": "dav\/appinfo\/v1\/webdav.php",
"repairlegacystoragesdone": "yes",
"scss.variables": "1507fc1bca1a3a31bdb702badb4c3449",
"shareapi_allow_links": "yes",
"shareapi_allow_mail_notification": "yes",
"shareapi_allow_public_notification": "no",
"shareapi_allow_public_upload": "yes",
"shareapi_default_expire_date": "yes",
"shareapi_enforce_links_password": "no",
"shareapi_expire_after_n_days": "30",
"shareapi_only_share_with_group_members": "yes",
"umgmt_show_last_login": "true",
"vendor": "nextcloud"
},
"dav": {
"buildCalendarSearchIndex": "yes",
"chunks_migrated": "1",
"enabled": "yes",
"installed_version": "1.9.2",
"regeneratedBirthdayCalendarsForYearFix": "yes",
"types": "filesystem"
},
"documents": {
"enabled": "no",
"installed_version": "0.13.1",
"ocsid": "168711",
"types": ""
},
"federatedfilesharing": {
"enabled": "yes",
"installed_version": "1.6.0",
"types": ""
},
"federation": {
"autoAddServers": "0",
"enabled": "yes",
"installed_version": "1.6.0",
"types": "authentication"
},
"files": {
"cronjob_scan_files": "500",
"enabled": "yes",
"installed_version": "1.11.0",
"types": "filesystem"
},
"files_accesscontrol": {
"enabled": "no",
"installed_version": "1.5.0",
"types": "filesystem"
},
"files_external": {
"allow_user_mounting": "yes",
"enabled": "yes",
"installed_version": "1.7.0",
"types": "filesystem",
"user_mounting_backends": "sftp,sharepoint,\OC\Files\Storage\SFTP_Key"
},
"files_pdfviewer": {
"enabled": "no",
"installed_version": "1.5.0",
"types": ""
},
"files_rightclick": {
"enabled": "no",
"installed_version": "0.13.0",
"types": ""
},
"files_sharing": {
"enabled": "yes",
"incoming_server2server_share_enabled": "no",
"installed_version": "1.8.0",
"outgoing_server2server_share_enabled": "no",
"types": "filesystem"
},
"files_texteditor": {
"enabled": "no",
"installed_version": "2.8.0",
"types": ""
},
"files_trashbin": {
"cronjob_user_offset": "1000",
"enabled": "yes",
"installed_version": "1.6.0",
"types": "filesystem,dav"
},
"files_versions": {
"enabled": "yes",
"installed_version": "1.9.0",
"types": "filesystem,dav"
},
"files_videoplayer": {
"enabled": "no",
"installed_version": "1.5.0",
"types": ""
},
"firstrunwizard": {
"enabled": "yes",
"installed_version": "2.5.0",
"types": "logging"
},
"gallery": {
"enabled": "yes",
"installed_version": "18.3.0",
"types": ""
},
"groupfolders": {
"enabled": "no",
"installed_version": "4.0.3",
"types": "filesystem,dav"
},
"impersonate": {
"enabled": "no",
"installed_version": "1.2.0",
"types": ""
},
"logreader": {
"enabled": "yes",
"installed_version": "2.1.0",
"types": ""
},
"lookup_server_connector": {
"enabled": "yes",
"installed_version": "1.4.0",
"types": "authentication"
},
"nextcloud_announcements": {
"enabled": "yes",
"installed_version": "1.5.0",
"pub_date": "Sat, 10 Dec 2016 00:00:00 +0100",
"types": "logging"
},
"notifications": {
"enabled": "no",
"installed_version": "0.2.3",
"types": "logging"
},
"oauth2": {
"enabled": "yes",
"installed_version": "1.4.2",
"types": "authentication"
},
"onlyoffice": {
"enabled": "no",
"installed_version": "1.3.0",
"skey": "1524663368476",
"types": "filesystem"
},
"ownnote": {
"enabled": "no",
"installed_version": "1.07",
"types": ""
},
"password_policy": {
"enabled": "yes",
"enforceNumericCharacters": "1",
"enforceUpperLowerCase": "1",
"installed_version": "1.6.0",
"minLength": "12",
"types": ""
},
"passwords": {
"backup_allowed": "true",
"enabled": "no",
"installed_version": "18.1",
"ocsid": "170480",
"types": ""
},
"privacy": {
"enabled": "yes",
"installed_version": "1.0.0",
"types": ""
},
"provisioning_api": {
"enabled": "yes",
"installed_version": "1.6.0",
"types": "prevent_group_restriction"
},
"recommendations": {
"enabled": "yes",
"installed_version": "0.4.0",
"types": ""
},
"richdocuments": {
"enabled": "no",
"installed_version": "2.0.8",
"types": "prevent_group_restriction"
},
"serverinfo": {
"enabled": "yes",
"installed_version": "1.6.0",
"types": ""
},
"sharebymail": {
"enabled": "no",
"installed_version": "1.4.0",
"sendpasswordmail": "no",
"types": "filesystem"
},
"sharepoint": {
"enabled": "no",
"installed_version": "1.2.0",
"types": "filesystem"
},
"support": {
"enabled": "yes",
"installed_version": "1.0.0",
"types": ""
},
"survey_client": {
"enabled": "yes",
"installed_version": "1.4.0",
"types": ""
},
"systemtags": {
"enabled": "yes",
"installed_version": "1.6.0",
"types": "logging"
},
"templateeditor": {
"enabled": "no",
"installed_version": "0.2",
"types": ""
},
"theming": {
"cachebuster": "11",
"color": "#000000",
"enabled": "yes",
"installed_version": "1.7.0",
"logoMime": "image\/png",
"logoheaderMime": "image\/png",
},
"twofactor_admin": {
"enabled": "no",
"installed_version": "0.2.0",
"types": ""
},
"twofactor_backupcodes": {
"enabled": "yes",
"installed_version": "1.5.0",
"types": ""
},
"twofactor_totp": {
"enabled": "no",
"installed_version": "2.1.2",
"types": ""
},
"unsplash": {
"enabled": "no",
"installed_version": "1.1.3",
"types": ""
},
"updatenotification": {
"calendar": "1.6.4",
"contacts": "3.0.5",
"core": "15.0.5.3",
"enabled": "yes",
"files_pdfviewer": "1.2.1",
"groupfolders": "2.0.4",
"installed_version": "1.6.0",
"onlyoffice": "2.0.4",
"theming": "1.4.5",
"twofactor_totp": "2.1.2",
"types": "",
"update_check_errors": "0"
},
"viewer": {
"enabled": "yes",
"installed_version": "1.0.0",
"types": ""
},
"workflowengine": {
"enabled": "yes",
"installed_version": "1.6.0",
"types": "filesystem"
}
}
}
Are you using external storage, if yes which one: local/smb/sftp/... No
Are you using encryption: yes/no
No
Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
No
Browser: Google Chrome v75.0.3770.100
Logs
Web server error log
No errors in the Apache logs but I get this message in the access log
POST /nextcloud/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json HTTP/1.1" 403 1569 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
Nextcloud log (data/nextcloud.log)
Nothing
Browser log
POST https://nextcloud-testenv/nextcloud/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json 403 (Forbidden)
On more thing to mention is that in Firefox, when I click on a folder or file to create a share link, there is no "+" sign in the first place. So it is disabled.
Same problem in v16.0.0 Beta 2.
In the browser, I get the following error:
jquery.js:8630 POST https://nc-testenv/nextcloud/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json 403 (Forbidden)
Facing the same issue on nextcloud 15.0.6 with Firefox 66.0.2. The system runs a minimal ubuntu 18.04 LTS container environment, configured with apache2, mariadb and redis. Interestingly, no entry in the log seems to be generated to help debugging, not even at log level "debug". There seems to be no trace in the system that indicates why generating a link failed. Not in the web interface, not in the system journal.
Upgraded my instance to nextcloud 15.0.7 today and link sharing seems to be working again!
Thanks for the update.
I've upgraded to 15.0.7 but it is still the same.
Can anyone from the NC team help?
What's the log saying?
Thanks for your help.
Actually, nothing in the logs appears when I try to generate a share link but I receive the error I mentioned above in the browser console though.
Try setting the loglevel to debug in the config.php and check again please
https://docs.nextcloud.com/server/16/admin_manual/configuration_server/logging_configuration.html
Also, please check your file permissions in the server directory. The whole directory needs to be accessible by the web server (e.g. sudo chown -R www-data:www-data nextcloud)
Thanks for your quick reply.
The loglevel is already set to 'debug'
'loglevel' => 0,
Also the permissions of the server directory was set correctly but I chowned it again just to be sure. Still the same problem.
Please note that I have two Nextcloud instances: production and test. The NC version for production is "15.0.5" and for the test is "15.0.7". Both have the same problem.
I just tried V16 "stable" but the problem persists.
Any suggestions?
sharing folder or file exception message :
"There was an error retrieving the share. Maybe the link is wrong, it was unshared, or it was deleted."
Have same issue appear after upgrade to 15.0.3. Login works fine, but "sharing folder" API is not working anymore. Error 403 forbidden on POST with path to /ocs/v2.php/apps/files_sharing/api/v1/shares?format=json. Exact message is "Access denied CSRF check failed". Since already signed, why this message ?
Please help
I've opened two tickets for this issue but it seems that the NC team is not interested.
There is nothing logged either in Nextcloud nor Nginx logs.
There is a misconfiguration in nextcloud website, links is catched within the browser
I'm not CSRF specialist, but please can anyone give us a suggestion to deal with this kind of security ?
Same here. No error messages whatsoever.
Looking ahead : it's linked with symfony application framework which is managing CSRF.
could be a simple question of misconfigurated rights in session handler.
Seems like I've got the same problem on NC 16.0.1. Is there any workaround for this?
CC @rullzer
Another thread here :
error message "There was an error retrieving the share. Maybe the link is wrong, it was unshared, or it was deleted." #15662
Hello how can we help? Any debugging scripts to launch ?
I'm getting the same problem with Nextcloud 16 current stable. Running with CentOS 7, apache and MariaDB. Not sure when the problem arose as I haven't used link share's since Nextcloud 14. Nothing relevant in the Nextcloud or apache logs. I haven't done the change to 4 byte character support yet.
About system : did you upgraded mariadb from 5 to 10?
I've fixed by chance my issue :) since I have found that database was corrupted.
Can't be repaired said "database created on mysql 5 and using mysql 10'
Done backup
Removed mariadb and processed with a fresh clean install of mariadb 10.3 which is for production.
restored database
All is now fixed.
Sharing working again 馃憤
Yes. Currently running Mariadb v10.4.6. I just ran the change to 4 byte character support but as I expected that made no difference.
@tekmedm: That sounds promising. Is there a guide on how to do that safely without losing the current data?
If not intalled do that first :
sudo yum install MariaDB-backup
Sqlbackup database one line:
mysqldump -u rootuser -p db_name > /backup/db_name.sql
Removing mariadb wont remove databases so you have to manually clean/ rename directory /var/lib/mysql
Using Yum remove all 10.4 mariadb galera-4 sqlbackup related package
Force repository on Mariah 10.3
etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB-10.3.14
baseurl=http://yum.mariadb.org/10.3.14/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Reinstall mariadb
Import Database
Recreate user / credentials
mysql your_db < db_name.sql
Authorize users on database
Good luck :)
Hi tekmedm, This has worked for me but it took me a while as I had several databases to backup and restore - not just nextcloud.
Thanks for your advice.
Perfect!
Have a nice day
@codesmaker Could that work for you as well?
Hi,
So I had mariadb-server v10.1. I've followed the same steps tekmedm mentioned above:
1- Backed up the database
2- Removed mariadb-server v10.1 and cleaned up
3- Installed mariadb-server v10.3
4- Restored the DB
5- Enabled MYSQL 4-byte support
And I had exactly the same error message "Unable to create a link share". Am I missing something?
Hello
Please Check space available on mysql fs
Try Enable MYSQL 4-byte support before restoration
Nothing in the logs?
@tekmedm I saw your post also in the already closed https://github.com/nextcloud/server/issues/11464
Today one of our users had the same problem. Creating a password protected shared link and when opening the share link he gets the CSRF error.
Solution was to open a "private tab" in firefox and open the link there. So obviously you can't be logged in to your account and open the "external" link in the same session.
Don't know if this is a bug or a feature...
referring to: https://github.com/nextcloud/server/issues/14861#issuecomment-494339090
I'm sorry I've never get this behaviour but what I understood is that when there is a database corruption or lack of space on FS, a CSRF message can appear. And no message in log, it cannot be written... Try repair database first, then depend on message you get a refresh could be useful.
Since backup exists, just try this :
cd /var/lib/mysql
replacing nameDATABASE nameTABLE with the name of the database or table that you want to check:
mysqlcheck nameDATABASE
mysqlcheck nameDATABASE nameTABLE
And for repairing (be sure to have a backup) mysqlcheck -r nameDATABASE
@tekmedm ok sorry then there was a misunderstanding. i guess i have to open a new issue then...
@tekmedm I'm not sure if it's possible to enable MYSQL 4-byte support before restoring the database. In the procedure here https://docs.nextcloud.com/server/15/admin_manual/configuration_database/mysql_4byte_support.html, it says that the database character set and collation should be set on Nextcloud database itself as you can see in this step:
ALTER DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
All the steps after that depend on the above step (enabling utf8mb4 in Nextcloud config file, etc). Is there something that I miss?
I've also double checked the available space on the filesystem and there was more than 12GB.
@kesselb No actually. There is nothing in the Nextcloud logs but in the Apache access logs, there is this:
192.168.0.42 - - [05/Jul/2019:20:27:14 +0200] "POST /nextcloud/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json HTTP/1.1" 403 1569 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"
As you can see, I get '403' forbidden error HTTP status code every time I try to create a share link for a file or folder. I'm not sure if it was the case when I was running Nextcloud v15.0.5. Now I'm running v16.0.2.
For utf8mb4 it's important that the database server is configured properly. Could you please disable utf8mb4, run occ maintenance:repair and try to create a new share link again? Please backup your database just in case!
@kesselb Thanks for your help!
So I've disabled 'utf8mb4' and ran 'occ maintenance:repair' and tried to create a share link but unfortunately got the same result and the same error message in the Apache access log.
Mind to try https://demo.nextcloud.com?
It worked when I tried the demo version.
@codesmaker
Alter database to change format in a database already created without utf8mb4 support.
My.cnf is where you enable utf8mb4 file contain something like this:
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
Would you mind to edit your initial post and add the information from the issue template: https://github.com/nextcloud/server/blob/master/.github/ISSUE_TEMPLATE/Bug_report.md?
@tekmedm Thanks for your help!
I've added the settings you suggested on the MariaDB server in /etc/mysql/my.cnf. I restarted MariaDB server but unfortunately no change.
@kesselb I've added all the information from the issue template.
I get the same issue, and I'm downgrading the mariaDB.. Hope it can work...
@helloxinxiang downgrading from what versions? Any news?
@helloxinxiang downgrading from what versions? Any news?
I was using MariaDB 10.4 and downgraded to 10.3, it works now. Thanks for your sharing!
OK. I'm already at v10.3 but still no joy :).
You're welcome!
I was at 10.4.6. I removed it and installed 10.3.16. I did not remove/restore databases. Just removed MariaDB 10.4.6, and installed 10.3.16 with the existing databases in place. Restarted httpd and it is working fine now.
I don't think I changed anything in the month since it was all working fine. I was surprised to see I couldn't share because about a month ago, it was broken when using an old MariaDB version and trying to enable utf8mb4 . I got it working by installing 10.4.6, and made sure sharing a folder worked. I have been trying to install OnlyOffice, but that was it. Nothing changed with the database.
I also got the "Unable to create a link share" error. My install uses PostgreSQL. From the logs I've seen trying to create the share gave me a 404 error instead of 403. No Nextcloud logs present related to this error.
I tried the steps suggested in issue https://github.com/nextcloud/server/issues/13933, though I did run that after the last update.
After reading https://github.com/nextcloud/server/issues/14861#issuecomment-508737831 I decided to try deleting all Nextcloud cookies. This fixed it for me.
Unfortunately the error has returned and clearing the cookies does not help anymore.
I will need a screenshot of your network requests.
Before you do anything, still on the development tools, there is a tab called network. Click on it and then the xhr filter. Do your action and screenshot the network log like this:

Also please click on the failing request and copy/paste the content of the response here.
I think I found the problem.
FWIW, this is the response:
{"ocs":{"meta":{"status":"failure","statuscode":404,"message":"Can\u2019t set expiration date more than 14 days in the future"},"data":[]}}
I have a max setting of 14 days. Today I happen to be in a different time zone than (east of) the server, but after setting my local (client) time to the same zone as the server, everything works again.
Over the last week I tried to reproduce the error every day or so, but it has worked every time so far. I will try to provide the information as soon as I reproduce the issue again.
I do have a forced expiration date of 2 days on link shares.
Closing then!
FYI, 18 will ship a newly revamped sharing ui with a far better integration of error handling and issues like those :)
My issue was different, after finally having the time to take closer look I noticed that for me the error was caused by two missing columns in the share table. Those columns where label and password_by_talk.
I guess the corresponding migrations somehow never ran. I just altered the table manually and link shares are working again.
The error is shown in the 403 response from the server on NC 16.02, but on older versions it was not.
Same here but I can create a share on the mobile app. I'm using 16.0.4
Nextcloud: 16.0.4
Same here but I CAN create a share link via WEBGUI and mobile APP.
Local clients has stopped working (<=2.6.1).
Apache2 access log shows:
POST /ocs/v2.php/apps/files_sharing/api/v1/shares?format=json HTTP/1.1" 403 840 "-" "Mozilla/5.0 (Windows) mirall/2.6.1stable-Win64 (build 20191105) (Nextcloud)
Im using MariaDB 10.1.43-0ubuntu0.18.04.1 (MySQL 4-byte support enabled by this guide: https://docs.nextcloud.com/server/16/admin_manual/configuration_database/mysql_4byte_support.html)
How can WEBGUI and APP working fine but local client not? Whats the different?
My problem occurs because i enforced password protection:
https://help.nextcloud.com/t/nextcloud-client-2-6-0-link-teilen-share-freigabe/61975/5
https://github.com/nextcloud/desktop/issues/1485
hits local client > 2.5.2