Can't login in nextcloud instance anymore

Nextcloud version: 13.0.1
Operating system and version: Ubuntu 16.04.5 LTS
Apache or nginx version: Apache 2.4.18
PHP version: PHP 7.1.24-1+ubuntu16.04.1+deb.sury.org+1

The issue you are facing: Suddenly we can no longer login to the nextcloud server by any means.

There hasn’t been any recent changes. Last NC update was on last april. It has been working well until now.

Today all logins are impossible. We have both normal users and via IMAP backend. The mail server works well.

Trying to log through the web interface shows the following error message:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

Is this the first time you’ve seen this error?: Yes

Steps to replicate it:

  1. Try to login either through web interface or desktop client

The output of nextcloud.log file:

{"reqId":"0hsdqh6g5mrLiwUFPT89","level":3,"time":"2018-11-29T11:23:10+00:00","remoteAddr":"[REDACTED]","user":"--","app":"PHP","method":"POST","url":"\/index.php\/login","message":"Error while sending QUERY packet. PID=515 at \/home\/[REDACTED]\/public_html\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Driver\/PDOStatement.php#105","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36","version":"13.0.1.1"}
{"reqId":"0hsdqh6g5mrLiwUFPT89","level":3,"time":"2018-11-29T11:23:10+00:00","remoteAddr":"[REDACTED]","user":"--","app":"PHP","method":"POST","url":"\/index.php\/login","message":"Error while sending QUERY packet. PID=515 at \/home\/[REDACTED]\/public_html\/3rdparty\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Driver\/PDOStatement.php#105","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36","version":"13.0.1.1"}
{"reqId":"0hsdqh6g5mrLiwUFPT89","level":3,"time":"2018-11-29T11:23:10+00:00","remoteAddr":"[REDACTED]","user":"--","app":"index","method":"POST","url":"\/index.php\/login","message":"Exception: {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\DriverException\",\"Message\":\"An exception occurred while executing 'SELECT `uid`, `password` FROM `oc_users` WHERE LOWER(`uid`) = LOWER(?)' with params [\\\"[REDACTED]\\\"]:\\n\\nSQLSTATE[HY000]: General error: 2006 MySQL server has gone away\",\"Code\":0,\"Trace\":\"#0 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/DBALException.php(128): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Statement.php(177): Doctrine\\\\DBAL\\\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'SELECT `uid`, `...', Array)\\n#2 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/legacy\\\/db\\\/statementwrapper.php(71): Doctrine\\\\DBAL\\\\Statement->execute(Array)\\n#3 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/User\\\/Database.php(223): OC_DB_StatementWrapper->execute(Array)\\n#4 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/User\\\/Manager.php(204): OC\\\\User\\\\Database->checkPassword(*** sensitive parameters replaced ***)\\n#5 \\\/home\\\/[REDACTED]\\\/public_html\\\/core\\\/Controller\\\/LoginController.php(254): OC\\\\User\\\\Manager->checkPasswordNoLogging(*** sensitive parameters replaced ***)\\n#6 [internal function]: OC\\\\Core\\\\Controller\\\\LoginController->tryLogin(*** sensitive parameters replaced ***)\\n#7 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(161): call_user_func_array(Array, Array)\\n#8 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(91): OC\\\\AppFramework\\\\Http\\\\Dispatcher->executeController(Object(OC\\\\Core\\\\Controller\\\\LoginController), 'tryLogin')\\n#9 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/App.php(115): OC\\\\AppFramework\\\\Http\\\\Dispatcher->dispatch(Object(OC\\\\Core\\\\Controller\\\\LoginController), 'tryLogin')\\n#10 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/Routing\\\/RouteActionHandler.php(47): OC\\\\AppFramework\\\\App::main('OC\\\\\\\\Core\\\\\\\\Control...', 'tryLogin', Object(OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer), Array)\\n#11 [internal function]: OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler->__invoke(Array)\\n#12 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Route\\\/Router.php(297): call_user_func(Object(OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler), Array)\\n#13 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/base.php(998): OC\\\\Route\\\\Router->match('\\\/login')\\n#14 \\\/home\\\/[REDACTED]\\\/public_html\\\/index.php(37): OC::handleRequest()\\n#15 {main}\",\"File\":\"\\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":115}","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36","version":"13.0.1.1"}
{"reqId":"0hsdqh6g5mrLiwUFPT89","level":3,"time":"2018-11-29T11:23:10+00:00","remoteAddr":"[REDACTED]","user":"--","app":"index","method":"POST","url":"\/index.php\/login","message":"Exception: {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\DriverException\",\"Message\":\"An exception occurred while executing 'SELECT `uid`, `password` FROM `oc_users` WHERE LOWER(`uid`) = LOWER(?)' with params [\\\"[REDACTED]\\\"]:\\n\\nSQLSTATE[HY000]: General error: 2006 MySQL server has gone away\",\"Code\":0,\"Trace\":\"#0 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/DBALException.php(128): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Statement.php(177): Doctrine\\\\DBAL\\\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'SELECT `uid`, `...', Array)\\n#2 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/legacy\\\/db\\\/statementwrapper.php(71): Doctrine\\\\DBAL\\\\Statement->execute(Array)\\n#3 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/User\\\/Database.php(223): OC_DB_StatementWrapper->execute(Array)\\n#4 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/User\\\/Manager.php(204): OC\\\\User\\\\Database->checkPassword(*** sensitive parameters replaced ***)\\n#5 \\\/home\\\/[REDACTED]\\\/public_html\\\/core\\\/Controller\\\/LoginController.php(254): OC\\\\User\\\\Manager->checkPasswordNoLogging(*** sensitive parameters replaced ***)\\n#6 [internal function]: OC\\\\Core\\\\Controller\\\\LoginController->tryLogin(*** sensitive parameters replaced ***)\\n#7 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(161): call_user_func_array(Array, Array)\\n#8 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(91): OC\\\\AppFramework\\\\Http\\\\Dispatcher->executeController(Object(OC\\\\Core\\\\Controller\\\\LoginController), 'tryLogin')\\n#9 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/App.php(115): OC\\\\AppFramework\\\\Http\\\\Dispatcher->dispatch(Object(OC\\\\Core\\\\Controller\\\\LoginController), 'tryLogin')\\n#10 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/Routing\\\/RouteActionHandler.php(47): OC\\\\AppFramework\\\\App::main('OC\\\\\\\\Core\\\\\\\\Control...', 'tryLogin', Object(OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer), Array)\\n#11 [internal function]: OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler->__invoke(Array)\\n#12 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Route\\\/Router.php(297): call_user_func(Object(OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler), Array)\\n#13 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/base.php(998): OC\\\\Route\\\\Router->match('\\\/login')\\n#14 \\\/home\\\/[REDACTED]\\\/public_html\\\/index.php(37): OC::handleRequest()\\n#15 {main}\",\"File\":\"\\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":115}","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36","version":"13.0.1.1"}
{"reqId":"0hsdqh6g5mrLiwUFPT89","level":3,"time":"2018-11-29T11:23:10+00:00","remoteAddr":"[REDACTED]","user":"--","app":"core","method":"POST","url":"\/index.php\/login","message":"Exception: {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\DriverException\",\"Message\":\"An exception occurred while executing 'SELECT `uid`, `password` FROM `oc_users` WHERE LOWER(`uid`) = LOWER(?)' with params [\\\"[REDACTED]\\\"]:\\n\\nSQLSTATE[HY000]: General error: 2006 MySQL server has gone away\",\"Code\":0,\"Trace\":\"#0 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/DBALException.php(128): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Statement.php(177): Doctrine\\\\DBAL\\\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'SELECT `uid`, `...', Array)\\n#2 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/legacy\\\/db\\\/statementwrapper.php(71): Doctrine\\\\DBAL\\\\Statement->execute(Array)\\n#3 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/User\\\/Database.php(223): OC_DB_StatementWrapper->execute(Array)\\n#4 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/User\\\/Manager.php(204): OC\\\\User\\\\Database->checkPassword(*** sensitive parameters replaced ***)\\n#5 \\\/home\\\/[REDACTED]\\\/public_html\\\/core\\\/Controller\\\/LoginController.php(254): OC\\\\User\\\\Manager->checkPasswordNoLogging(*** sensitive parameters replaced ***)\\n#6 [internal function]: OC\\\\Core\\\\Controller\\\\LoginController->tryLogin(*** sensitive parameters replaced ***)\\n#7 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(161): call_user_func_array(Array, Array)\\n#8 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/Http\\\/Dispatcher.php(91): OC\\\\AppFramework\\\\Http\\\\Dispatcher->executeController(Object(OC\\\\Core\\\\Controller\\\\LoginController), 'tryLogin')\\n#9 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/App.php(115): OC\\\\AppFramework\\\\Http\\\\Dispatcher->dispatch(Object(OC\\\\Core\\\\Controller\\\\LoginController), 'tryLogin')\\n#10 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/AppFramework\\\/Routing\\\/RouteActionHandler.php(47): OC\\\\AppFramework\\\\App::main('OC\\\\\\\\Core\\\\\\\\Control...', 'tryLogin', Object(OC\\\\AppFramework\\\\DependencyInjection\\\\DIContainer), Array)\\n#11 [internal function]: OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler->__invoke(Array)\\n#12 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Route\\\/Router.php(297): call_user_func(Object(OC\\\\AppFramework\\\\Routing\\\\RouteActionHandler), Array)\\n#13 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/base.php(998): OC\\\\Route\\\\Router->match('\\\/login')\\n#14 \\\/home\\\/[REDACTED]\\\/public_html\\\/index.php(37): OC::handleRequest()\\n#15 {main}\",\"File\":\"\\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":115}","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36","version":"13.0.1.1"}
{"reqId":"0hsdqh6g5mrLiwUFPT89","level":3,"time":"2018-11-29T11:23:10+00:00","remoteAddr":"[REDACTED]","user":"--","app":"core","method":"POST","url":"\/index.php\/login","message":"Exception: {\"Exception\":\"Doctrine\\\\DBAL\\\\Exception\\\\DriverException\",\"Message\":\"An exception occurred while executing 'SELECT `id`, `numeric_id`, `available`, `last_checked` FROM `oc_storages` WHERE `id` IN (?)' with params [\\\"local::\\\\\\\/home\\\\\\\/[REDACTED]\\\\\\\/public_html\\\\\\\/data\\\\\\\/\\\"]:\\n\\nSQLSTATE[HY000]: General error: 2006 MySQL server has gone away\",\"Code\":0,\"Trace\":\"#0 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/DBALException.php(128): Doctrine\\\\DBAL\\\\Driver\\\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException))\\n#1 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Connection.php(855): Doctrine\\\\DBAL\\\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOMySql\\\\Driver), Object(Doctrine\\\\DBAL\\\\Driver\\\\PDOException), 'SELECT `id`, `n...', Array)\\n#2 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/DB\\\/Connection.php(195): Doctrine\\\\DBAL\\\\Connection->executeQuery('SELECT `id`, `n...', Array, Array, NULL)\\n#3 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Query\\\/QueryBuilder.php(206): OC\\\\DB\\\\Connection->executeQuery('SELECT `id`, `n...', Array, Array)\\n#4 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/DB\\\/QueryBuilder\\\/QueryBuilder.php(214): Doctrine\\\\DBAL\\\\Query\\\\QueryBuilder->execute()\\n#5 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/Cache\\\/StorageGlobal.php(60): OC\\\\DB\\\\QueryBuilder\\\\QueryBuilder->execute()\\n#6 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/Cache\\\/StorageGlobal.php(72): OC\\\\Files\\\\Cache\\\\StorageGlobal->loadForStorageIds(Array)\\n#7 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/Cache\\\/Storage.php(93): OC\\\\Files\\\\Cache\\\\StorageGlobal->getStorageInfo('local::\\\/home\\\/ne...')\\n#8 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/Cache\\\/Storage.php(71): OC\\\\Files\\\\Cache\\\\Storage::getStorageById('local::\\\/home\\\/ne...')\\n#9 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/Cache\\\/Cache.php(102): OC\\\\Files\\\\Cache\\\\Storage->__construct(Object(OCA\\\\RansomwareProtection\\\\StorageWrapper))\\n#10 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/Storage\\\/Common.php(331): OC\\\\Files\\\\Cache\\\\Cache->__construct(Object(OCA\\\\RansomwareProtection\\\\StorageWrapper))\\n#11 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/Storage\\\/Wrapper\\\/Wrapper.php(392): OC\\\\Files\\\\Storage\\\\Common->getCache('appdata_oc7ampe...', Object(OCA\\\\RansomwareProtection\\\\StorageWrapper))\\n#12 \\\/home\\\/[REDACTED]\\\/public_html\\\/apps\\\/ransomware_protection\\\/lib\\\/StorageWrapper.php(412): OC\\\\Files\\\\Storage\\\\Wrapper\\\\Wrapper->getCache('appdata_oc7ampe...', Object(OCA\\\\RansomwareProtection\\\\StorageWrapper))\\n#13 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/View.php(1314): OCA\\\\RansomwareProtection\\\\StorageWrapper->getCache('appdata_oc7ampe...')\\n#14 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/View.php(1371): OC\\\\Files\\\\View->getCacheEntry(Object(OCA\\\\RansomwareProtection\\\\StorageWrapper), 'appdata_oc7ampe...', '\\\/appdata_oc7amp...')\\n#15 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/Node\\\/Root.php(198): OC\\\\Files\\\\View->getFileInfo('\\\/appdata_oc7amp...')\\n#16 [internal function]: OC\\\\Files\\\\Node\\\\Root->get('\\\/appdata_oc7amp...')\\n#17 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/Node\\\/LazyRoot.php(64): call_user_func_array(Array, Array)\\n#18 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/Node\\\/LazyRoot.php(141): OC\\\\Files\\\\Node\\\\LazyRoot->__call('get', Array)\\n#19 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/AppData\\\/AppData.php(79): OC\\\\Files\\\\Node\\\\LazyRoot->get('appdata_oc7ampe...')\\n#20 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Files\\\/AppData\\\/AppData.php(105): OC\\\\Files\\\\AppData\\\\AppData->getAppDataFolder()\\n#21 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Template\\\/JSCombiner.php(94): OC\\\\Files\\\\AppData\\\\AppData->getFolder('core')\\n#22 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Template\\\/JSResourceLocator.php(113): OC\\\\Template\\\\JSCombiner->process('\\\/home\\\/nextcloud...', 'core\\\/js\\\/merged-...', 'core')\\n#23 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Template\\\/JSResourceLocator.php(69): OC\\\\Template\\\\JSResourceLocator->cacheAndAppendCombineJsonIfExist('\\\/home\\\/nextcloud...', 'core\\\/js\\\/merged-...')\\n#24 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Template\\\/ResourceLocator.php(78): OC\\\\Template\\\\JSResourceLocator->doFind('js\\\/merged-templ...')\\n#25 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/TemplateLayout.php(306): OC\\\\Template\\\\ResourceLocator->find(Array)\\n#26 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/TemplateLayout.php(146): OC\\\\TemplateLayout::findJavascriptFiles(Array)\\n#27 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/legacy\\\/template.php(207): OC\\\\TemplateLayout->__construct('error', '')\\n#28 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/Template\\\/Base.php(132): OC_Template->fetchPage()\\n#29 \\\/home\\\/[REDACTED]\\\/public_html\\\/lib\\\/private\\\/legacy\\\/template.php(351): OC\\\\Template\\\\Base->printPage()\\n#30 \\\/home\\\/[REDACTED]\\\/public_html\\\/index.php(65): OC_Template::printExceptionErrorPage(Object(Doctrine\\\\DBAL\\\\Exception\\\\DriverException))\\n#31 {main}\",\"File\":\"\\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Driver\\\/AbstractMySQLDriver.php\",\"Line\":115}","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36","version":"13.0.1.1"}
{"reqId":"F91euCBHsc5GqOHA9Hxl","level":4,"time":"2018-11-29T11:23:11+00:00","remoteAddr":"[REDACTED]","user":"--","app":"webdav","method":"PROPFIND","url":"\/remote.php\/dav\/files\/lsalas\/","message":"Exception: {\"Exception\":\"Sabre\\\\DAV\\\\Exception\\\\ServiceUnavailable\",\"Message\":\"Doctrine\\\\DBAL\\\\Exception\\\\DriverException: An exception occurred while executing 'SELECT `id`, `uid`, `login_name`, `password`, `name`, `type`, `remember`, `token`, `last_activity`, `last_check`, `scope` FROM `oc_authtoken` WHERE `token` = ?' with params [\\\"abd0e3cda76cbe9eb2cafddb97e4d0bc6c0a5cbd79f296131fa2f8f698638656fa8f4061bf5bd8b538e1086804fc0637194c9211bdc0b600986ee623091bae51\\\"]:\\n\\nSQLSTATE[HY000]: General error: 2006 MySQL server has gone away\",\"Code\":0,\"Trace\":\"#0 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Auth\\\/Plugin.php(201): OCA\\\\DAV\\\\Connector\\\\Sabre\\\\Auth->check(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#1 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Auth\\\/Plugin.php(150): Sabre\\\\DAV\\\\Auth\\\\Plugin->check(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#2 [internal function]: Sabre\\\\DAV\\\\Auth\\\\Plugin->beforeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#3 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/sabre\\\/event\\\/lib\\\/EventEmitterTrait.php(105): call_user_func_array(Array, Array)\\n#4 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(466): Sabre\\\\Event\\\\EventEmitter->emit('beforeMethod', Array)\\n#5 \\\/home\\\/[REDACTED]\\\/public_html\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#6 \\\/home\\\/[REDACTED]\\\/public_html\\\/apps\\\/dav\\\/lib\\\/Server.php(283): Sabre\\\\DAV\\\\Server->exec()\\n#7 \\\/home\\\/[REDACTED]\\\/public_html\\\/apps\\\/dav\\\/appinfo\\\/v2\\\/remote.php(35): OCA\\\\DAV\\\\Server->exec()\\n#8 \\\/home\\\/[REDACTED]\\\/public_html\\\/remote.php(164): require_once('\\\/home\\\/nextcloud...')\\n#9 {main}\",\"File\":\"\\\/home\\\/[REDACTED]\\\/public_html\\\/apps\\\/dav\\\/lib\\\/Connector\\\/Sabre\\\/Auth.php\",\"Line\":163}","userAgent":"Mozilla\/5.0 (Windows) mirall\/2.3.3 (build 1) (Nextcloud)","version":"13.0.1.1"}
{"reqId":"ytq28NnQPVgwGXo5S8MW","level":0,"time":"2018-11-29T11:23:11+00:00","remoteAddr":"[REDACTED]","user":"--","app":"core","method":"GET","url":"\/index.php\/login","message":"Scss is disabled for \/home\/[REDACTED]\/public_html\/core\/css\/jquery-ui-fixes.scss, ignoring","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36","version":"13.0.1.1"}
{"reqId":"ytq28NnQPVgwGXo5S8MW","level":0,"time":"2018-11-29T11:23:11+00:00","remoteAddr":"[REDACTED]","user":"--","app":"core","method":"GET","url":"\/index.php\/login","message":"Scss is disabled for \/home\/[REDACTED]\/public_html\/core\/css\/server.scss, ignoring","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36","version":"13.0.1.1"}
{"reqId":"ytq28NnQPVgwGXo5S8MW","level":0,"time":"2018-11-29T11:23:11+00:00","remoteAddr":"[REDACTED]","user":"--","app":"core","method":"GET","url":"\/index.php\/login","message":"Scss is disabled for \/home\/[REDACTED]\/public_html\/core\/css\/share.scss, ignoring","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36","version":"13.0.1.1"}
{"reqId":"ytq28NnQPVgwGXo5S8MW","level":0,"time":"2018-11-29T11:23:11+00:00","remoteAddr":"[REDACTED]","user":"--","app":"core","method":"GET","url":"\/index.php\/login","message":"Scss is disabled for \/home\/[REDACTED]\/public_html\/core\/css\/jquery.ocdialog.scss, ignoring","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.102 Safari\/537.36","version":"13.0.1.1"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'forcessl' => true,
  'overwriteprotocol' => 'https',
  'instanceid' => '[REDACTED]',
  'passwordsalt' => '[REDACTED]',
  'secret' => '[REDACTED]',
  'trusted_domains' =>
  array (
    0 => '[DOMAIN_REDACTED]',
  ),
  'datadirectory' => '/home/[REDACTED]/public_html/data',
  'overwrite.cli.url' => 'https://[DOMAIN_REDACTED]',
  'dbtype' => 'mysql',
  'version' => '13.0.1.1',
  'dbname' => '[REDACTED]',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '[REDACTED]',
  'dbpassword' => '[REDACTED]',
  'logtimezone' => 'UTC',
  'installed' => true,
  'default_language' => 'es',
  'user_backends' =>
  array (
    0 =>
    array (
      'class' => 'OC_User_IMAP',
      'arguments' =>
      array (
        0 => '{[DOMAIN_REDACTED]:993/imap/ssl/novalidate-cert}',
        1 => '[DOMAIN_REDACTED]',
      ),
    ),
  ),
  'appstoreurl' => 'https://apps.nextcloud.com/api/v0',
  'skeletondirectory' => '',
  'theme' => '',
  'mail_domain' => '[DOMAIN_REDACTED]',
  'mail_from_address' => 'nube',
  'loglevel' => 0,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => 6379,
    'timeout' => 0,
    'password' => '',
  ),
  'trashbin_retention_obligation' => '8,14',
  'versions_retention_obligation' => '30,60',
  'updatechecker' => true,
  'maintenance' => false,
);

The output of your Apache/nginx/system log in /var/log/____: there are no errors here

The output of .htaccess:

<IfModule mod_headers.c>
  <IfModule mod_setenvif.c>
    <IfModule mod_fcgid.c>
       SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
       RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    </IfModule>
    <IfModule mod_proxy_fcgi.c>
       SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>
  </IfModule>

  <IfModule mod_env.c>
    # Add security and privacy related headers
    Header set X-Content-Type-Options "nosniff"
    Header set X-XSS-Protection "1; mode=block"
    Header set X-Robots-Tag "none"
    Header set X-Download-Options "noopen"
    Header set X-Permitted-Cross-Domain-Policies "none"
    SetEnv modHeadersAvailable true
  </IfModule>

  # Add cache control for static resources
  <FilesMatch "\.(css|js|svg|gif)$">
    Header set Cache-Control "max-age=15778463"
  </FilesMatch>

  # Let browsers cache WOFF files for a week
  <FilesMatch "\.woff$">
    Header set Cache-Control "max-age=604800"
  </FilesMatch>
</IfModule>
<IfModule mod_php5.c>
  php_value upload_max_filesize 511M
  php_value post_max_size 511M
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value always_populate_raw_post_data -1
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_php7.c>
  php_value upload_max_filesize 511M
  php_value post_max_size 511M
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP_USER_AGENT}  DavClnt
  RewriteRule ^$         /remote.php/webdav/          [L,R=302]
  RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L]
  RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
  RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
  RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
  RewriteRule ^remote/(.*) remote.php [QSA,L]
  RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
  RewriteCond %{REQUEST_URI} !^/.well-known/(acme-challenge|pki-validation)/.*
  RewriteRule ^(?:\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
</IfModule>
<IfModule mod_mime.c>
  AddType image/svg+xml svg svgz
  AddEncoding gzip svgz
</IfModule>
<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
  ModPagespeed Off
</IfModule>
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

ErrorDocument 403 //
ErrorDocument 404 //

More info. The log file var/log/mysql/error.log is full of:

2018-11-29T12:38:27.149837Z 3360 [Note] Aborted connection 3360 to db: '[REDACTED]' user: '[REDACTED]' host: 'localhost' (Got timeout reading communication packets)

But mysqlcheck -uroot --all-databases reports all databases are OK

Stopping and starting mysql service shows in the log:

2018-11-29T12:42:55.550440Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

2018-11-29T12:43:02.838191Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2018-11-29T12:43:03.040516Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-11-29T12:43:03.042667Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.24-0ubuntu0.16.04.1) starting as process 11563 ...
2018-11-29T12:43:03.075067Z 0 [Note] InnoDB: PUNCH HOLE support available
2018-11-29T12:43:03.075116Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-11-29T12:43:03.075126Z 0 [Note] InnoDB: Uses event mutexes
2018-11-29T12:43:03.075139Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-11-29T12:43:03.075148Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-11-29T12:43:03.075156Z 0 [Note] InnoDB: Using Linux native AIO
2018-11-29T12:43:03.075568Z 0 [Note] InnoDB: Number of pools: 1
2018-11-29T12:43:03.075797Z 0 [Note] InnoDB: Using CPU crc32 instructions
2018-11-29T12:43:03.078574Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2018-11-29T12:43:03.094110Z 0 [Note] InnoDB: Completed initialization of buffer pool
2018-11-29T12:43:03.097834Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2018-11-29T12:43:03.168701Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2018-11-29T12:43:03.240841Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2018-11-29T12:43:03.240946Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2018-11-29T12:43:03.263722Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2018-11-29T12:43:03.265300Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2018-11-29T12:43:03.265322Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2018-11-29T12:43:03.265700Z 0 [Note] InnoDB: Waiting for purge to start
2018-11-29T12:43:03.315904Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 1741351509
2018-11-29T12:43:03.316410Z 0 [Note] Plugin 'FEDERATED' is disabled.
2018-11-29T12:43:03.323912Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2018-11-29T12:43:03.371174Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2018-11-29T12:43:03.371220Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2018-11-29T12:43:03.371281Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2018-11-29T12:43:03.371322Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2018-11-29T12:43:03.632349Z 0 [Note] Event Scheduler: Loaded 0 events
2018-11-29T12:43:03.632648Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.24-0ubuntu0.16.04.1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)
2018-11-29T12:43:03.806036Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2018-11-29T12:43:04.410901Z 0 [Note] InnoDB: Buffer pool(s) load completed at 181129  7:43:04
2018-11-29T12:43:15.182273Z 4 [Note] Aborted connection 4 to db: '[REDACTED]' user: '[REDACTED]' host: 'localhost' (Got timeout reading communication packets)
2018-11-29T12:43:26.161303Z 5 [Note] Aborted connection 5 to db: '[REDACTED]' user: '[REDACTED]' host: 'localhost' (Got timeout reading communication packets)
2018-11-29T12:43:40.223693Z 7 [Note] Aborted connection 7 to db: '[REDACTED]' user: '[REDACTED]' host: 'localhost' (Got timeout reading communication packets)
2018-11-29T12:43:41.588691Z 11 [Note] Aborted connection 11 to db: '[REDACTED]' user: '[REDACTED]' host: 'localhost' (Got timeout reading communication packets)
2018-11-29T12:43:44.318302Z 13 [Note] Aborted connection 13 to db: '[REDACTED]' user: '[REDACTED]' host: 'localhost' (Got timeout reading communication packets)