While working with Magento, developers may face many problems. However, those are easy to fix if you know the right solutions for them and have proper documentation. But sometimes, complex issues may require you to hire a Magento 2 developer for a quicker time to market your project. Today I am going to share the most common issues with Magento 2.4.1 and its solutions.

Common Magento 2 Issues

  • Composer version
  • Installation issue
  • JS/CSS loading issue
  • Re-indexing
  • Speed up Magento 2 store
  • CSS cache
  • Admin session timeout & account sharing.

Composer Version

You might face an error of “Undefined class constant ‘PRE_COMMAND_RUN’” while downloading Magento using composer. This is a composer version error. That means the version of composer you are using is the older version, and Magento requires the composer to version 1.9 or above it.

You can check the current composer version by running the command “composer –version.”

To update the composer version, you need to run the following command, and it will upgrade your composer to the latest version.

composer self-update

Installation Issue

As we all know that Magento comes with lots of inbuilt features and requires a properly configured server. Any miss-configuration may lead you to errors. Magento required a dedicated server with a minimum of 2GB of memory. We often face the error of memory limit like “the Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes)” while using composer.

You can increase the memory limit from the php.ini file by setting up the variable “memory_limit.”

You can find the loaded php configuration file by using the below command.

php –ini

Sometimes, after increasing the memory limit, we can not fix the issue, and we still face the same problem. We have another solution for the same. You will need to pass the memory limit parameter while executing the command like below.

php -d memory_limit=-1 composer.phar require [PACKAGE_NAME]

JS/CSS Loading Issue

Many times after successfully installing Magento, we face the issue of Js and CSS loading. Either js/css goes to 404, or the wrong path shows for the pub directory.

You need to change in below file if the path is showing wrong for the Js/Css

open file /vendor/magento/framework/View/Element/Template/File/Validator.php and find

$realPath = $this->fileDriver->getRealPath($path);

replace with :

$realPath = str_replace(‘\’, ‘/’, $this->fileDriver->getRealPath($path));

If the file paths are correct and still js and CSS are not loading, then change in the below file.

open file app/etc/di.xml in Magento install dir, find

replace with :


After making changes in the above file, please deploy the static content. Run below command from Magento root directory.

php bin/magento setup:static-content:deploy


In Magento 2, many users may see the issue with the message “One or more indexes are invalid.” In Magento 1, admin users had the option to reindex data from the admin area. But we do not have this option in Magento 2. We need to add cron jobs for index management or run the command from the Magento root directory manually.

Setting up the cron jobs.

php bin/magento cron:run

Run indexer from the command line.

php bin/magento indexer:reindex

Speed Up Magento 2

It is difficult to believe that Magento is slow. But the users who faced this issue are unaware of the optimization process of Magento. Magento 2 is not dead by default as many possible factors cause the performance of Magento.

Here Are A Few Easy Steps To Improve Magento’s Performance

System Requirement

Make sure your Magento fulfills all the system requirements mentioned here.

Optimize Images

Make sure you are using optimized and resized images. In addition, the lazyload will help you with page speed.

Enable Flat Catalog

This is the one primary reason to slow down the Magento. Magento uses the database’s EAV structure, and the EAV structure’s read speed is less than flat tables. So you must be using the flat catalog. You can enable this feature from the Store > Configuration > Catalog in the admin area.

Enable Varnish

Varnish cache will drastically improve page speed. Magento recommends using a varnish cache rather than using a built-in cache. If you are not aware of how to configure varnish, check out our step-by-step guide here.


Memcached is free open-source caching, which will help you increase your Magento store’s performance by decreasing load on the database.

CSS Cache

We often faced the issue like adding style in CSS file but not reflecting in the frontend. This is a common problem due to caching. Try running the below commands from the Magento root directory.

rm -rf var/cache/* var/page_cache/* pub/static/*

php bin/magento setup:static-content:deploy

php bin/magento cache:flush

If you are using any third-party cache, you must refresh the third-party cache to reflect changes in the frontend.

Admin Session

Sometimes admin users face problems while they are login into the admin panel. A simple way is to log out from the admin panel and log in again. This will reset the admin session.

While in development, Magento forces you to change your password after a limited period for security reasons. It is always a good practice to update passwords regularly. But you can disable this feature for the development environment. Follow the below steps to disable the feature.

Store > Configuration > Advance > Admin > Password Change

Final Words

We have covered the most common issues and solutions in this post. But Magento is a large and complex system. So there are many more issues users encounter. Sometimes, these issues may be challenging, and then is when you decide to hire a Magento 2 developer to help you out. But if you are a technical expert that knows the tricks of Magento 2 and all you need is a gentle nudge in the right direction, then you can always go to the StackExchange for more help.