Internal Server Error after moving DB

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version : 25.0.4
Operating system and version : Debian GNU/Linux 11 (bullseye)
Apache or nginx version : 2.4.56
PHP version : 8.2

The issue you are facing:
I migrated my MariaDB database to a different drive and it works as intended for other programs but when I go to nextcloud, I get a internal server error.

Is this the first time you’ve seen this error? (Y/N):

Steps to replicate it:

The output of your Nextcloud log in Admin > Logging:

Can't Access

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

<?php
$CONFIG = array (
  'instanceid' => 'XXXX',
  'passwordsalt' => 'XXXXX',
  'secret' => 'XXXX',
  'trusted_domains' =>
  array (
    0 => 'XXXX',
    1 => 'XXXX',
    2 => 'XXXX',
  ),
  'datadirectory' => '/srv/dev-disk-by-uuid-a57fd38d-505d-4724-9020-d74be9e7f41d/nextcloud_data/',
  'dbtype' => 'mysql',
  'version' => '25.0.4.1',
  'overwrite.cli.url' => 'http://XXXX',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '3306',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'XXXX',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpport' => '465',
  'mail_smtpsecure' => 'ssl',
  'mail_from_address' => 'XXXX',
  'mail_domain' => 'gmail.com',
  'mail_smtpname' => 'XXXX',
  'mail_smtppassword' => 'XXXX',
  'maintenance' => false,
  'log_type' => 'file',
  'logfile' => 'nextcloud.log',
  'loglevel' => 3,
  'logdateformat' => 'F d, Y H:i:s',
  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\HEIC',
    1 => 'OC\\Preview\\TIFF',
    2 => 'OC\\Preview\\Movie',
    3 => 'OC\\Preview\\MKV',
    4 => 'OC\\Preview\\MP4',
    5 => 'OC\\Preview\\AVI',
    6 => 'OC\\Preview\\PNG',
    7 => 'OC\\Preview\\BMP',
    8 => 'OC\\Preview\\JPEG',
    9 => 'OC\\Preview\\GIF',
  ),
  'memories.exiftool' => '/var/www/html/nextcloud/apps/memories/exiftool-bin/exiftool-amd64-glibc',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'default_phone_region' => 'US',
  'htaccess.RewriteBase' => '/',
  'app_install_overwrite' =>
  array (
    0 => 'duplicatefinder',
  ),
  'memories.vod.ffmpeg' => '/usr/bin/ffmpeg',
  'memories.vod.ffprobe' => '/usr/bin/ffprobe',
  'memories.vod.path' => '/var/www/html/nextcloud/apps/memories/exiftool-bin/go-vod-amd64',
  'memories.vod.disable' => false,
);

The output of your Apache/nginx/system log in /var/log/____:

[Sat Jun 10 00:00:02.360415 2023] [mpm_prefork:notice] [pid 1421] AH00163: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Sat Jun 10 00:00:02.360428 2023] [core:notice] [pid 1421] AH00094: Command line: '/usr/sbin/apache2'
[Sat Jun 10 15:35:49.051115 2023] [mpm_prefork:notice] [pid 1421] AH00170: caught SIGWINCH, shutting down gracefully
PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20190902/imagick.so (/usr/lib/php/20190902/imagick.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/imagick.so.so (/usr/lib/php/20190902/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[Sat Jun 10 15:35:49.275208 2023] [mpm_prefork:notice] [pid 1032077] AH00163: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Sat Jun 10 15:35:49.275271 2023] [core:notice] [pid 1032077] AH00094: Command line: '/usr/sbin/apache2'
[Sat Jun 10 15:43:06.445199 2023] [mpm_prefork:notice] [pid 1032077] AH00170: caught SIGWINCH, shutting down gracefully
PHP Warning:  PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20190902/imagick.so (/usr/lib/php/20190902/imagick.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/imagick.so.so (/usr/lib/php/20190902/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[Sat Jun 10 15:44:28.540064 2023] [mpm_prefork:notice] [pid 1650] AH00163: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Sat Jun 10 15:44:28.540156 2023] [core:notice] [pid 1650] AH00094: Command line: '/usr/sbin/apache2'

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{"reqId":"MPImEwBRqPgzO9ycOLe2","level":3,"time":"May 18, 2023 11:14:08","remoteAddr":"152.89.196.144","user":"--","app":"richdocuments","method":"GET","url":"/?XDEBUG_SESSION_START=phpstorm","message":"Failed to fetch the Collabora capabilities endpoint: cURL error 7: Failed to connect to homenas.local port 8080: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://homenas.local:8080/apps/richdocumentscode/proxy.php?req=/hosting/capabilities","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36","version":"25.0.4.1","exception":{"Exception":"GuzzleHttp\\Exception\\ConnectException","Message":"cURL error 7: Failed to connect to homenas.local port 8080: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://homenas.local:8080/apps/richdocumentscode/proxy.php?req=/hosting/capabilities","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Handler/CurlFactory.php","line":158,"function":"createRejection","class":"GuzzleHttp\\Handler\\CurlFactory","type":"::"},{"file":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Handler/CurlFactory.php","line":110,"function":"finishError","class":"GuzzleHttp\\Handler\\CurlFactory","type":"::"},{"file":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Handler/CurlHandler.php","line":47,"function":"finish","class":"GuzzleHttp\\Handler\\CurlFactory","type":"::"},{"file":"/var/www/html/nextcloud/lib/private/Http/Client/DnsPinMiddleware.php","line":113,"function":"__invoke","class":"GuzzleHttp\\Handler\\CurlHandler","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php","line":35,"function":"OC\\Http\\Client\\{closure}","class":"OC\\Http\\Client\\DnsPinMiddleware","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Middleware.php","line":31,"function":"__invoke","class":"GuzzleHttp\\PrepareBodyMiddleware","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/RedirectMiddleware.php","line":71,"function":"GuzzleHttp\\{closure}","class":"GuzzleHttp\\Middleware","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Middleware.php","line":63,"function":"__invoke","class":"GuzzleHttp\\RedirectMiddleware","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/HandlerStack.php","line":75,"function":"GuzzleHttp\\{closure}","class":"GuzzleHttp\\Middleware","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php","line":331,"function":"__invoke","class":"GuzzleHttp\\HandlerStack","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php","line":168,"function":"transfer","class":"GuzzleHttp\\Client","type":"->"},{"file":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php","line":187,"function":"requestAsync","class":"GuzzleHttp\\Client","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Http/Client/Client.php","line":218,"function":"request","class":"GuzzleHttp\\Client","type":"->"},{"file":"/var/www/html/nextcloud/apps/richdocuments/lib/Service/CapabilitiesService.php","line":136,"function":"get","class":"OC\\Http\\Client\\Client","type":"->"},{"file":"/var/www/html/nextcloud/apps/richdocuments/lib/Service/CapabilitiesService.php","line":74,"function":"refetch","class":"OCA\\Richdocuments\\Service\\CapabilitiesService","type":"->"},{"file":"/var/www/html/nextcloud/apps/richdocuments/lib/Service/CapabilitiesService.php","line":90,"function":"getCapabilities","class":"OCA\\Richdocuments\\Service\\CapabilitiesService","type":"->"},{"file":"/var/www/html/nextcloud/apps/richdocuments/lib/Capabilities.php","line":112,"function":"hasDrawSupport","class":"OCA\\Richdocuments\\Service\\CapabilitiesService","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/CapabilitiesManager.php","line":75,"function":"getCapabilities","class":"OCA\\Richdocuments\\Capabilities","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/JSConfigHelper.php","line":166,"function":"getCapabilities","class":"OC\\CapabilitiesManager","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/TemplateLayout.php","line":229,"function":"getConfig","class":"OC\\Template\\JSConfigHelper","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/legacy/OC_Template.php","line":184,"function":"__construct","class":"OC\\TemplateLayout","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->"},{"file":"/var/www/html/nextcloud/lib/base.php","line":817,"function":"printPage","class":"OC\\Template\\Base","type":"->"},{"file":"/var/www/html/nextcloud/lib/base.php","line":1144,"function":"init","class":"OC","type":"::"},{"file":"/var/www/html/nextcloud/index.php","line":34,"args":["/var/www/html/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/nextcloud/3rdparty/guzzlehttp/guzzle/src/Handler/CurlFactory.php","Line":210,"message":"Failed to fetch the Collabora capabilities endpoint: cURL error 7: Failed to connect to homenas.local port 8080: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://homenas.local:8080/apps/richdocumentscode/proxy.php?req=/hosting/capabilities","exception":{},"CustomMessage":"Failed to fetch the Collabora capabilities endpoint: cURL error 7: Failed to connect to homenas.local port 8080: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://homenas.local:8080/apps/richdocumentscode/proxy.php?req=/hosting/capabilities"}}

Also when i run occ i get this error

An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/html/nextcloud/lib/private/DB/Connection.php:139
Stack trace:
#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\DB\Connection->connect()
#1 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /var/www/html/nextcloud/lib/private/DB/Connection.php(261): Doctrine\DBAL\Connection->executeQuery()
#3 /var/www/html/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection->executeQuery()
#4 /var/www/html/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(281): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /var/www/html/nextcloud/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /var/www/html/nextcloud/lib/private/AppConfig.php(183): OC\AppConfig->loadConfigValues()
#7 /var/www/html/nextcloud/lib/private/AppConfig.php(374): OC\AppConfig->getApps()
#8 /var/www/html/nextcloud/lib/private/legacy/OC_App.php(967): OC\AppConfig->getValues()
#9 /var/www/html/nextcloud/lib/private/Server.php(725): OC_App::getAppVersions()
#10 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC\{closure}()
#11 /var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#12 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#13 /var/www/html/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#14 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#15 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(184): OC\AppFramework\Utility\SimpleContainer->get()
#16 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#17 /var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#18 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#19 /var/www/html/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#20 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#21 /var/www/html/nextcloud/lib/private/Server.php(1119): OC\AppFramework\Utility\SimpleContainer->get()
#22 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC\{closure}()
#23 /var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#24 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#25 /var/www/html/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#26 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#27 /var/www/html/nextcloud/lib/private/Server.php(2070): OC\AppFramework\Utility\SimpleContainer->get()
#28 /var/www/html/nextcloud/lib/private/Files/View.php(117): OC\Server->getLockingProvider()
#29 /var/www/html/nextcloud/lib/private/Server.php(462): OC\Files\View->__construct()
#30 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\Server->OC\{closure}()
#31 /var/www/html/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#32 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(129): Pimple\Container->offsetGet()
#33 /var/www/html/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#34 /var/www/html/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(57): OC\ServerContainer->query()
#35 /var/www/html/nextcloud/lib/private/Server.php(1472): OC\AppFramework\Utility\SimpleContainer->get()
#36 /var/www/html/nextcloud/lib/base.php(617): OC\Server->boot()
#37 /var/www/html/nextcloud/lib/base.php(1144): OC::init()
#38 /var/www/html/nextcloud/console.php(48): require_once('...')
#39 /var/www/html/nextcloud/occ(11): require_once('...')

I forgot to add the steps to replicate.

Steps to replicate:

  1. Move MariaDB database files location
  2. Open Nextcloud

It’s saying it can’t each the server configured essentially.

Set dbportto '' rather than `‘3306’. It’s not used in NC.

Perrhaps are your other programs that use the same MariaDB server are using UNIX sockets rather than TCP?

Can you please provide the log from your MariaDB server?

You’re not using containers by chance?

Changing dbport didn’t make a difference

Here is the log from MariaDB

Jun 10 17:31:58 homenas /etc/mysql/debian-start[32244]: Looking for 'mariadb' as: /usr/bin/mariadb
Jun 10 17:31:58 homenas /etc/mysql/debian-start[32244]: Looking for 'mariadb-check' as: /usr/bin/mariadb-check
Jun 10 17:31:58 homenas /etc/mysql/debian-start[32244]: This installation of MariaDB is already upgraded to 10.5.18-MariaDB.
Jun 10 17:31:58 homenas /etc/mysql/debian-start[32244]: There is no need to run mysql_upgrade again for 10.5.19-MariaDB.
Jun 10 17:31:58 homenas /etc/mysql/debian-start[32244]: You can use --force if you still want to run mysql_upgrade
Jun 10 17:31:58 homenas debian-start[32255]: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)

Though now I do notice that ‘/run/mysqld/mysqld.sock’ is the wrong path.

Heres the output of --printdefaults if it helps

mariadbd would have been started with the following arguments:
--socket=/srv/dev-disk-by-uuid-a57fd38d-505d-4724-9020-d74be9e7f41d/mysqldata/mysqld.sock --user=mysql --pid-file=/run/mysqld/mysqld.pid --basedir=/usr --datadir=/srv/dev-disk-by-uuid-a57fd38d-505d-4724-9020-d74be9e7f41d/mysqldata/ --tmpdir=/tmp --lc-messages-dir=/usr/share/mysql --lc-messages=en_US --skip-external-locking --bind-address=127.0.0.1 --log_error=/var/log/mysql/mariadb.err --expire_logs_days=10 --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci

socket should be /srv/dev-disk-by-uuid-a57fd38d-505d-4724-9020-d74be9e7f41d/mysqldata/mysqld.sock

Okay, so I’d suggest this to make your config work (it’ll also make things less fragile and more obvious if you make other changes down the road):

Config.php:

'dbhost' => "localhost:/srv/dev-disk-by-uuid-a57fd38d-505d-4724-9020-d74be9e7f41d/mysqldata/mysqld.sock',
'dbport' => '"

I suspect the reason this worked before the move is because IIRC localhost is interpreted specially to use a UNIX socket. And prior to your changes the default path worked.

This part shouldn’t be necessary for NC: If you want to get rid of that startup error about the socket you’ll probably need to adjust or add the session parameter on one more more files in /etc/mysql/*.cnf

Works! Thank you so much!