Troubleshooting Magento: “One or More Indexers Are Invalid” Error

one or more indexers are invalid. make sure your magento cron job is running.

Have you been in a situation where you were working on Magento 2, and then a system message showed “One or more indexers are invalid.” Make sure your Magento cron job is running.”? If this is your first time having this issue, you might not know what to do. Then you can follow this guide to resolve the problem quickly.

indexers are invalid

What Are Magento Inderxers and Cron Job?

Indexers

Indexing in Magento is an important process that improves your online store’s performance by organizing and transforming data like products and categories. Magento uses indexers to consolidate this data into specialized tables, ensuring that your storefront runs smoothly. Whenever there are changes to the data, Magento initiates the indexing process to update the necessary adjustments in the database. This process efficiently distributes the data to the right tables, ultimately enhancing your store’s overall performance.

Cron Job

Cron Job is a critical feature in Magento 2. Its mission is to generate commands so that activities can automatically occur at a set time in the future. Some activities that require cron jobs are:

  • Catalog price rules
  • Newsletters
  • Generating Google sitemaps
  • Customer Alerts/Notifications (product price change, product back in stock)
  • Reindexing
  • Private sales (for Magento Commerce)
  • Automatic updating of currency rates
  • All Magento e-mails (including order confirmation and transactional)

As you can see from the list, reindex also requires the role of corn job. So if it isn’t working correctly, the indexing process will be delayed.

Fix “One Or More Inderxers Are Invalid” Error In Magento 2

To help the system run smoothly after the updates in the database, we need to check if the reindex mode and the cron job are correctly set.

Select the reindex mode

Step 1: Go to Admin, choose System > Index management

Step 2: Select the Indexer you want to reindex. Or you can select all if you aren’t sure what to be reindexed.

Step 3: Expand the Action menu, and select the action you want to apply to the selected indexers. 3 types of action you can choose are:

  • Update on Save
  • Update by schedule
  • Invalidate index

Run the command for reindex

  • Use this command to see all indexers in Magento 2:
php bin/magento indexer:info
  • To reindex all the indexers in Magento 2, use:
php bin/magento indexer:reindex
  • To reindex only one specific indexer:
bin/magento indexer:reindex [indexer]

E.g., To reindex only customer_grid, use

bin/magento indexer:reindex [customer_grid]

Check and run cron jobs

By default, Magento 2 will create cron jobs to reindex indexers

#~ 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
  • If the cron jobs for Magento 2 are missing, then you need to reinstall them:
php bin/magento cron:install
  • To run all Magento 2 cron jobs, use this command:
php bin/magento cron:run

After finishing all these steps, return to the Index management sector. You should see that all indexers’ statuses have been changed to Ready.

indexers in magento 2

Go back to the dashboard, and close the pop-up message “One or more indexers are invalid. Make sure your cron job is running properly” message. Refresh the page, and the message should not appear again now.

Conclusion

Indexers and cron jobs are essential players that ensure your Magento system runs smoothly. Hopefully, after reading this tutorial post, you know how to efficiently deal with the issue of indexers that are not valid.

Besides the invalid indexers, there are more common issues that you might confront in your Magento site, such as You Don’t Have Permission To Access On This Server, The Promotional Code You Entered Is Not Valid, Exception Printing Is Disabled By Default For Security Reasons,… To get the right solutions for all of these, make sure to follow Tigren’s blog!

Leave a Reply

Your email address will not be published. Required fields are marked *