7

I am trying to move a Drupal 8 site, but I get the following error:

The website encountered an unexpected error. Please try again later.

InvalidArgumentException: Class "\Drupal\system\Controller\Http4xxController" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (line 29 of core/lib/Drupal/Core/DependencyInjection/ClassResolver.php).

How do I properly move a Drupal 8 site from a server to another one?

What I did was importing the database, moving the files, and changing the database connection settings.

4
  • Read this it may helps drupalize.me/blog/201511/simple-drupal-7-drupal-8-migration Mar 8, 2016 at 6:05
  • 1
    The OP is talking about moving a Drupal 8 site from a server to another one, not about migrating a Drupal 7 site to Drupal 8.
    – apaderno
    Mar 8, 2016 at 6:07
  • Did you clear your cache before switching environments? Migrating should be as easy as file and db transfer and updating the settings.php. Those errors usually happen when you don't flush the cache after an update
    – nizz0k
    Mar 28, 2019 at 13:37
  • Also, are people really upvoting this? the title is very generic and has been addressed on here numerous times, if the error is useful, then the question should have that in the title...
    – nizz0k
    Mar 28, 2019 at 13:43

2 Answers 2

10

In a nutshell, moving a Drupal website from one host to another is just a matter of moving the files and the database, and then connecting the two.

However, there are several things you need to consider:

  1. Server environment should be as close as possible to each other. This way you will avoid any errors that are a result of having different software/configuration on production and development servers. Compare PHP version, MySQL version, Apache modules, and setup of all of these components.

  2. File permissions need to be set up properly. I've seen problems caused by this dozens of times. In short, the Apache user needs to have enough permissions to access and work with your Drupal website. Otherwise, it won't be able to write and even read files in some cases. Read more about how to secure correct file permissions here.

  3. If you do this manually via FTP, make sure that all files are transferred. It often happens that one of the files wasn't uploaded completely. This usually results in broken Drupal site and random errors. Other ways to migrate a D8 website are Drush, Git or simply zipping the whole directory and using wget on the other server to transfer it directly from server to server.

  4. You will need to clear all caches. Preferrably you won't have CSS/JS aggregation and page caching turned on when you migrate the database. You can do this through SQL/phpMyAdmin. See this answer for more information.

  5. Update trusted hosts in /sites/default/settings.php file.

  6. Once you can access your website, update the temporary directory path at /admin/config/media/file-system, as well as any other settings (e.g. of contrib modules) that store server paths/domain name.

See also docs on migrating a D7 site. Most items are still applicable for D8.


If you follow the guidelines above, you will avoid most issues. If you still have problems after migration, post here the exact log messages you're receiving.

Regarding the error you already posted: I'd make sure that all files are there, and that your cache is cleared before doing anything else.

Hope this helps.

1
  • Sadly I cannot plus any more than the one I have. This boils it down so nicely and worked for me going from a very big site on Drupal 7.53 / PHP 5.5.9 on Ubuntu 14.04 TO PHP 7.0.32 on Ubuntu 16.04 Sep 28, 2018 at 21:56
1

I got the same error when porting Drupal 8 to localhost.

In my case I found a solution visiting mysite/core/install.php location.

There I saw a detailed error: when backing up from /admin/config/development/backup_migrate some tables were missing. So I backed up full database from phpmyadmin, and problem was solved.

1
  • 1
    yeah, backup and migrate has a lot of problems in my limited experience with 8, I do it all through PMA or the CLI
    – nizz0k
    Mar 28, 2019 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.