One or more indexers are invalid. Make sure your Magento cron job is running that appears after you change your system configurations in Magento 2 . Many Magento users are facing this error and don’t know how to fix it. This tutorial, Magesolution explains to you the cause of this issue and certainly, all working solutions to deal with it
What are Magento 2 indexers?
As you may know, Magento 2 comes with a very complicated database structure, there are a lot of data in the database such as Catalog, prices, users, store, store views…When you make changes to your Magento 2 website, Magento 2 system will start the indexing process to update adjustments to the website’s database. The indexing process will distribute data to the special tables to enhance your website’s performance.
What is Magento cron job?
The cron job is a helpful feature by Linux, the free operating system for the user. The cron job will generate a command or a script that is appropriate to the task you want to do. Instead of manual working, the cronjob enables running automatically in exact time and date. There are several Magento features that require at least one cron job, which schedules activities to happen in the future. A partial list of these activities are
- Catalog price rules
- Newsletters
- Creating Google sitemaps
- Customer Alerts/Notifications (product price change, product back in stock)
- Reindexing
- Private sales (Magento Commerce only)
- Automatic updating of currency rates
- All Magento e-mails (including order confirmation and transactional)
Magento depends on proper cron job configuration for many crucial system functions, including indexing. Failure to set it up properly means Magento won’t feature as expected
Read more: Magento 2 Cron job: Everything you need to know
Cause of the error: One or more indexers are invalid. make sure your magento cron job is running
Sometimes, this is just a common notification from Magento 2 system to indicate that your website needs to be reindexed to update information.
There may be another cause of this error that is related to cronjob on your server. By default, the reindex process occurs automatically on your server if cronjobs are set rightly. Once there is something wrong with your cronjobs and the reindex process does not start automatically. And you will have to start the reindex process manually.
How to solve it?
To resolve this problem, we will check the reindex mode that is currently set up and run the reindex syntax. We will also check if cron jobs for Magento 2 are working rightly.
Method 1
- Log into your server via SSH
- Move to the document root for your Magento folder. and ensure you are logged in as someone who has permissions over that document root.
- Follow this command:
#Normal Way bin/magento cron:install #Overwrite current crontab bin/magento cron:install --force
After finishing, you should receive a message similar to this: Crontab has been generated and saved
Method 2
Setting the reindex mode in Magento 2 backend
- Move to Magento 2 admin dashboard, Navigate to System > Index management
- Choose the Indexer you need to reindex, or you can choose all if you don’t know what to be reindexed
- In the Action dropdown menu, choose the action you want to apply to the chosen indexes. There are 3 types of action we can use to choose indexers:
- Update on Save: Reindex automatically when the data is updated (must use custom code to trigger reindexing)
- Update by Schedule: index tables are updated by Cron jobs by the configured schedule. Remember that: does not support the
customer_grid
indexer, you can’t reindex this indexer using this way - Invalidate index: Disable the selected indexer
Run the reindex command
To see the list of all indexers in Magento 2, follow this syntax
php bin/magento indexer:info
After that, you use the command to reindex all the indexers in Magento 2
php bin/magento indexer:reindex
Also, if you want to reindex only a specific indexer, you can follow this command
bin/magento indexer:reindex [indexer]
For instance, you want to reindex only catalog_category_product
, use this command
bin/magento indexer:reindex catalog_category_product
Check and run cronjob
By default, Magento 2 gennerate Cron jobs as follow to reindex indexer
#~ MAGENTO START * * * * * /usr/bin/php /var/www/html/magento2/bin/magento cron:run | grep -v Ran jobs by schedule >> /var/www/html/magento2/var/log/magento.cron.log * * * * * /usr/bin/php /var/www/html/magento2/update/cron.php >> /var/www/html/magento2/var/log/update.cron.log * * * * * /usr/bin/php /var/www/html/magento2/bin/magento setup:cron:run >> /var/www/html/magento2/var/log/setup.cron.log #~ MAGENTO END
You can check if these cron jobs were added to your crobtab by this syntax
crontab -l
If the cron jobs for Magento 2 is missing, we will need to reinstall them by following this command:
php bin/magento cron:install
To start running all Magento 2 cronjobs using this syntax
php bin/magento cron:run
Lastly, you move to Magento 2 admin dashboard and navigate to index management section. You will see that all indexer’s statuses are Ready.
Conclusion
That’s all about the One or more indexers are invalid. make sure your Magento cron job is running and how to fix this issue in Magento 2. We hope you find it useful . Magesolution is one of the leading Magento solutions providers and magento website development services in the world. We provide high-quality products and services, specifically eCommerce, Web, and magento mobile apps development that will meet every simple to complex requirement.