Moved DB to different VM - NC throwing undebug-able 500 errors

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face: is for home/non-enterprise users. If you’re running a business, paid support can be accessed via 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:


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


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 (eg, 18.0.2): 17.0.2 Stable
Operating system and version (eg, Ubuntu 20.04): 20.04
Apache or nginx version (eg, Apache 2.4.25): 2.4.41
PHP version (eg, 7.1): 7.2.31-1

The issue you are facing:
Nextcloud not talking to Database after DB migration

Is this the first time you’ve seen this error? (Y/N):
Steps to replicate it:
(I have 1 Web server, and a whole other DB server. these are on different IPs)

  1. Stopped Apache2 to ensure nothing new written to DB on Webserver
  2. Mysql Dump on Database Server
  3. Scp the .sql dump onto Webserver
  4. Installed mysql-server and all dependencies required for mysql activities onto webserver
  5. adjusted config.php to match the new IP (localhost)
  6. Imported nextcloud db
  7. created mysql user matching the config.php expected values
  8. Granted (to be safe) ALL privileges on whole of Mysql to this user
  9. Flushed privileges
  10. Restarted apache2
  11. Accessed Same Webserver IP as always -> 500 error.

The output of your Nextcloud log in Admin > Logging:

No logs are being generated

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

$CONFIG = array (
  'log_type' => 'syslog',
  'logfile' => '',
  'syslog_tag' => 'Nextcloud',
  'loglevel' => '0',
  'logdateformat' => 'F d, Y H:i:s',
  'instanceid' => 'xxxxxxx',
  'passwordsalt' => 'xxxxxxx',
  'secret' => 'xxxxxxx',
  'trusted_domains' =>
  array (
          0 => 'xxxxxxx',
          1 => 'xxxxxxx',
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => 'http://xxxx',
  'dbname' => 'xxxxxxxx',
  'dbhost' => 'localhost:3306', <--- The reason for the port here, is the webserver used to have "dbip:port" here, which always worked. (Old was 192.167.xxxx:2400) should you wonder.
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_xxxxxxxx',
  'dbpassword' => 'xxxxxxxxxx',
  'installed' => true,
  'has_internet_connection' => true,
  'enable_previews' => true,
  'debug' => true,
  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\MP3',
    1 => 'OC\\Preview\\MP4',
    2 => 'OC\\Preview\\AVI',
    3 => 'OC\\Preview\\PDF',
    4 => 'OC\\Preview\\MKV',
    5 => 'OC\\Preview\\Movie',
    6 => 'OC\\Preview\\PDF',
    7 => 'OC\\Preview\\Image',
    8 => 'OC\\Preview\\JPG',
    9 => 'OC\\Preview\\JPEG',
    10 => 'OC\\Preview\\PNG',
  'maintenance' => false,

The output of your Apache/nginx/system log in /var/log/____:
All I got to offer here is the below type errors. - - [18/Nov/2020:14:19:16 +0000] "GET / HTTP/1.1" 500 477 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36" 

If I revert the changes in config.php back to the database server ip:port and restart apache2 it works immediately, Login page arrives and its usable.

Please also note that I have tried the new db user + its password locally on the webserver to see if it could access the nextcloud db inside mysql locally - worked fine. Unfortunately I struggle to debug this as there are no logs coming out what so ever when pointing at the new “local” mysql server within the webserver.

I welcome any and all guidance and advise, and I have backups of the whole db from the database server (its still alive) so I can easily drop the db on the webserver and re-import if needed.

I am no expert, but something tells me there is a mismatch between the DB that the database server had, and what is being imported into mysql server on the webserver. Either utf8 character settings or something.
I did follow this guide;

So after install on webserver, I DID create an empty db with the same name + the whole “CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci” on the end
I did this step as my config.php says something about ‘mysql.utf8mb4’ => true,.

Please help.


not sure how to “close” this, but I ended up taking a full backup of the VMs content locally, and rebuild everything from scratch.