How to troubleshoot Internal Server Error?

Site was running great, but then after a server power cycle I’m getting an Internal Server Error. :frowning:

How do I troubleshoot it?

The last thing I did to it was set up previews/thumbnails (this guide) and the smtp mail settings… nothing else.

So I tried removing previews from config.php, nothing, power cycled again. Ran the previews cron command:

sudo -u www php /usr/local/www/nextcloud/occ preview:pre-generate

and I get…

An unhandled exception has been thrown: Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory in /usr/local/www/nextcloud/lib/private/DB/Connection.php:68 Stack trace: #0 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(420): OC\DB\Connection->connect() #1 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(380): Doctrine\DBAL\Connection->getDatabasePlatformVersion() #2 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(324): Doctrine\DBAL\Connection->detectDatabasePlatform() #3 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(683): Doctrine\DBAL\Connection->getDatabasePlatform() #4 /usr/local/www/nextcloud/lib/private/DB/Connection.php(155): Doctrine\DBAL\Connection->setTransactionIsolation(2) #5 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(195): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager)) #6 /usr/local/www/nextcloud/lib/private/DB/ConnectionFactory.php(157): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager)) #7 /usr/local/www/nextcloud/lib/private/Server.php(748): OC\DB\ConnectionFactory->getConnection('mysql', Array) #8 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server)) #9 /usr/local/www/nextcloud/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('OCP\\IDBConnecti...') #10 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\ServerContainer->query('OCP\\IDBConnecti...') #11 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server)) #12 /usr/local/www/nextcloud/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('DatabaseConnect...') #13 /usr/local/www/nextcloud/lib/private/Server.php(1664): OC\ServerContainer->query('DatabaseConnect...') #14 /usr/local/www/nextcloud/lib/private/Server.php(421): OC\Server->getDatabaseConnection() #15 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server)) #16 /usr/local/www/nextcloud/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('OC\\Authenticati...') #17 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(70): OC\ServerContainer->query('OC\\Authenticati...', true) #18 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(100): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass)) #19 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Authenticati...') #20 /usr/local/www/nextcloud/lib/private/ServerContainer.php(150): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...', true) #21 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(70): OC\ServerContainer->query('OC\\Authenticati...', true) #22 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(100): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass)) #23 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(115): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Authenticati...') #24 /usr/local/www/nextcloud/lib/private/ServerContainer.php(150): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...', true) #25 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\ServerContainer->query('OC\\Authenticati...') #26 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server)) #27 /usr/local/www/nextcloud/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('OC\\Authenticati...') #28 /usr/local/www/nextcloud/lib/private/Server.php(433): OC\ServerContainer->query('OC\\Authenticati...') #29 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server)) #30 /usr/local/www/nextcloud/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('OC\\User\\Session') #31 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\ServerContainer->query('OC\\User\\Session') #32 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server)) #33 /usr/local/www/nextcloud/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('UserSession') #34 /usr/local/www/nextcloud/lib/private/Server.php(1540): OC\ServerContainer->query('UserSession') #35 /usr/local/www/nextcloud/lib/private/Server.php(801): OC\Server->getUserSession() #36 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server)) #37 /usr/local/www/nextcloud/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('OC\\App\\AppManag...') #38 /usr/local/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\ServerContainer->query('OC\\App\\AppManag...') #39 /usr/local/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server)) #40 /usr/local/www/nextcloud/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('AppManager') #41 /usr/local/www/nextcloud/lib/private/Server.php(1835): OC\ServerContainer->query('AppManager') #42 /usr/local/www/nextcloud/lib/private/legacy/app.php(347): OC\Server->getAppManager() #43 /usr/local/www/nextcloud/lib/private/legacy/app.php(114): OC_App::getEnabledApps() #44 /usr/local/www/nextcloud/lib/base.php(645): OC_App::loadApps(Array) #45 /usr/local/www/nextcloud/lib/base.php(1089): OC::init() #46 /usr/local/www/nextcloud/console.php(48): require_once('/usr/local/www/...') #47 /usr/local/www/nextcloud/occ(11): require_once('/usr/local/www/...')

So I tried the db…

root@cloud:/usr/local/www/nextcloud # mysql -uroot -pEnter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

What can I do?

The error message says all, Nextcloud cannot connect to your database. Make sure that it is up-and-running and that the given socket is valid. Furthermore you should use the search function of this forum to find additional information how this can be done. This kind of questions are asked and answered regularly.

https://help.nextcloud.com/search?q=Can%E2%80%99t%20connect%20to%20local%20MySQL%20server%20through%20socket

I wasn’t finding my scenario.

root@cloud: # service mysql-server status
mysql-server does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable

Hmm how could this be???

Any idea what I can do here on? I’m not really finding much…

2020-04-14T08:35:20.314977Z 0 [Note] InnoDB: Uses event mutexes 2020-04-14T08:35:20.314983Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() 2020-04-14T08:35:20.314989Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 2020-04-14T08:35:20.315208Z 0 [Note] InnoDB: Number of pools: 1 2020-04-14T08:35:20.315546Z 0 [Note] InnoDB: Using CPU crc32 instructions 2020-04-14T08:35:20.316604Z 0 [Note] InnoDB: Initializing buffer pool, total siz 2020-04-14T08:35:20.395135Z 0 [Note] InnoDB: Completed initialization of buffer 2020-04-14T08:35:20.403618Z 0 [ERROR] InnoDB: The Auto-extending innodb_system data file '/var/db/mysql/ibdata1' is of a different size 4864 pages (rounded down to MB) than specified in the .cnf file: initial 8192 pages, max 0 (relevant if non-zero) pages! 2020-04-14T08:35:20.403643Z 0 [ERROR] InnoDB: Plugin initialization aborted with Generic error 2020-04-14T08:35:20.713101Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 2020-04-14T08:35:20.713127Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2020-04-14T08:35:20.713135Z 0 [ERROR] Failed to initialize builtin plugins. 2020-04-14T08:35:20.713139Z 0 [ERROR] Aborting

I found that it’s actually in /usr/local/etc/mysql/my.cnf
I changed it to 64M to resolve that error.

Now a new error:
Unsupported redo log format. The redo log was created with MariaDB 10.3.22.

Yet when I run mysql -V :
mysql Ver 15.1 Distrib 10.3.22-MariaDB, for FreeBSD11.3 (amd64) using

Either way, when I run:
root@cloud:/tmp # mysqladmin -u root -p shutdown
Enter password:
mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (38)' Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
root@cloud:/tmp # mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (38)

Hello,

Have you ever tried that?

sudo -u www-data occ maintenance:repair

Thanks for the reply. Yes, I get a huge error output as shown in post 1.

I think what happened was that when installing libreoffice, it removed MariaDB. I reinstalled MariaDB which removed libreoffice and mysql. But I’m still seeing the issues the same…

What is your operating system?

If your operating system is debian.
When you tried to reinstall mariadb, did you try this: sudo apt purge mariadb-server
sudo apt install mariadb-server?

No, I’m on FreeBSD. I want to avoid purging as I’m trying to access my database not delete it.

What if you make a backup of your database and try to reinstall mariadb?