Table of Contents
Have you ever come across this message while working in Magento 2? “One or more indexers are invalid. Make sure your Magento cron job is running.”
If it’s your first time seeing it, don’t worry—it’s a common issue and quite easy to fix once you understand what it means. This guide will explain what indexers and cron jobs are in Magento 2, why the error appears, and provide a step-by-step solution to fix it.
Understanding Indexers and Cron Jobs in Magento 2?
What Are Indexers?
Magento manages a large amount of data, such as product details, categories, and prices.
To speed up your website, Magento organizes or “indexes” this data to make it easier for the system to process. When you make updates, like adding a new product, Magento needs to refresh this organized data. This is known as reindexing. Indexers are the tools Magento uses to update the data this way. If indexers aren’t functioning correctly, your store might not display the latest information, and you’ll encounter that error message.
What Is a Cron Job?
A cron job is a task that runs by itself at specific times. In Magento, cron jobs handle essential tasks like:
- Sending out newsletters
- Updating product prices
- Reindexing data
- Sending order confirmation emails
- Creating Google sitemaps
- Updating currency rates
If cron jobs are not functioning, Magento cannot reindex your data, which will result in the “invalid indexers” error message.
How to Fix the “One or More Indexers Are Invalid” Error
To resolve the “One or More Indexers Are Invalid” Error, you need to check two main things:
- Ensure the reindex mode is set correctly.
- Verify that cron jobs are configured properly.
Step 1: Check and Set the Reindex Mode
- Go to your Magento Admin Panel.
- Click on System > Index Management.
- You will see a list of indexers. Select the ones you want to fix, or choose all if you’re not sure.
- Open the Actions dropdown. You have several options to choose from:
- Update on Save – Makes the system reindex right away whenever you save any changes. It’s immediate.
- Update by Schedule – Reindexing happens automatically based on scheduled cron jobs.
- Invalidate Index – Marks the index as needing an update. It tells the system that an update is required.
- Update on Save – Makes the system reindex right away whenever you save any changes. It’s immediate.
Step 2: Run Reindex Commands Manually (Using Command Line)
To check all indexers, run:
php bin/magento indexer:infoTo reindex everything:
php bin/magento indexer:reindexTo reindex a specific indexer (example for customer_grid):
php bin/magento indexer:reindex customer_gridStep 3: Check If Magento Cron Jobs Are Running
Magento should have the following cron jobs set in your system:
* * * * * /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.logIf you don’t have these set up, you can reinstall the cron jobs using this command:
php bin/magento cron:installTo run all the Magento cron jobs right away:
php bin/magento cron:runStep 4: Refresh Index Management
Once you’ve reindexed and made sure cron is working:
- Go back to System > Index Management in the Admin Panel.
- The indexers should now show as Ready.
- Return to the dashboard and refresh the page.
- The error message should be gone!
Conclusion
Indexers and cron jobs are essential parts of Magento, ensuring your store operates smoothly. If you encounter a message stating “One or more indexers are invalid. Make sure your Magento cron job is running,” it typically indicates one of two issues:
1. Your data requires reindexing.
2. Your cron jobs are not functioning correctly.
By following the above-described steps, you can swiftly resolve the issue and get back to managing your store.
Learn how to fix other common Magento errors such as “An error has happened during application run”, “There has been an error processing your request”, the Permission Denied error, Session Size Limit Exceeded, and “libpng warning: iCCP: known incorrect sRGB profile” error.