I recently moved a module from one location to another location and I am getting a ClassNotFoundException. Is there something similar to Registry Rebuild Module that can help rebuild the registry?

6 Answers 6


In addition to the usual cache rebuild, the additional need to restart the web server is due to a decision in Drupal 8 to be 'fast by default' use the APC Classloader if it is available. It is faster, but it doesn't necessarily catch changes as you make them. To not have to restart your web server during development, you can set your local environment to not try to use a better-for-production class loader.

For instance, in local.settings.php add:

$settings['class_loader_auto_detect'] = FALSE;

Via, and more background information at, what to do when developing a Drupal 8 module and a class file just isn't being loaded even though it is definitely there.

  • 2
    A php-fpm restart was necessary for me.
    – Weboide
    Commented Dec 19, 2016 at 14:08
  • Wow, thanks. Searched for hours and this fixed my issue! Commented Apr 24, 2021 at 7:16
  • Worked for me. Afterwards, I could remove this line and it still works.
    – Arla
    Commented Jan 12, 2022 at 12:58
  • You can clear the APCu cache by executing apcu_clear_cache() once, if you don't want to restart php-fpm. Commented Dec 15, 2023 at 13:33

In Drupal 8 the equivalent of Registry Rebuild is built in to Cache Rebuild. If your site is not accessible you will need to use Drush. Its an indispensable tool in D8 for just this reason.

drush cr

  • If you don't have access to drush, which is definitely the easiest option, then you can also use rebuild.php after enabling it in settings.php. Drupal 8 has no class registry, but class names with their namespace are often stored somewhere, for example form and controller classes are stored in the router table, so you need to rebuild that.
    – Berdir
    Commented Apr 6, 2015 at 16:58

"drush cr" may not always work. You may have to restart your Web server to pick up new file locations. This is due to some caching at that level.

  • after moving a module containing an entity i had to restart the webserver too !
    – rémy
    Commented Apr 1, 2016 at 7:32
  • After moving a module from my custom folder to my contrib folder, I also had to restart my webserver. Just reinstalling and clearing the cache was not enough.
    – dbj44
    Commented Sep 29, 2017 at 9:56

I recently got this issue of "class not found" with a custom module. The strange thing is that this problem occurred in a multi-sites installation after installation of new site on server. But the issue never pop-up before with other sites with same modules and configuration. Thus it is very strange. I tried all sort of cache clearing, composer updates, restarts and so on. Also tried to replicate the installation on local computer and it worked fine in this case.

I really can't figure out what could be the explanation and why it happens specifically on a "sub" site and not on the others.

The only solution I could implement is for this particular setting is

$settings['class_loader_auto_detect'] = FALSE;

which is working but does not bring any clue on the issue.

Any idea on the direction to look for is welcome. Thanks


The easiest solution could be visiting www.yoursite.com/core/install.php location on your website.

If that doesn't solve your problem take a look at https://www.drupal.org/documentation/rebuild for further debugging which gives an exhaustive list of what could have gone wrong in your installation.


You can also call following path /core/rebuild.php like: mydrupalsite.test/core/rebuild.php

Your Answer

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

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