Magento 2 Common Problems & Solutions


#1

Magento2 Common Problems & Solutions

The Magento 2 environment can provide a number of benefits to the right site administrator; however, there are moments where things just go wrong and need to be addressed. We have compiled a list of issues that we see often and their solutions.

Admin Password Reset

If it has been awhile since accessing the site backend and you have forgotten the password or there was a recent change to the password and you are finding yourself locked out. You can reset this password by accessing your Magento 2 database and locating the ‘admin_user’ table. In this table locate the password field and replace it with an MD5 encrypted password of your choosing. You should now have access to the admin dashboard of your site.

CSS Changes Not Showing

Sometimes when making specific changes your site’s CSS, you’ll notice that though you have saved the file the change is not reflecting on the site. Magento 2 utilizes an extensive caching system that is native to the application. To alleviate the site cache please follow the steps list below:

  1. Remove the cache files themselves:

    rm -rf var/di/* var/generation/* var/cache/* var/log/* var/page_cache/* var/session/* var/view_preprocessed/* pub/static/*
    

    Note: Please be careful with an ‘rm -rf’ command. This command is both “recursive” and “forced.” It will remove content from with the directory specified and will do it for every single file without confirming the deletion. ‘rm -rf’ can be a silent killer of sites and systems if misused.

  2. Re-deploy the content for the Magento site.

    php bin/magento setup:static-content:deploy
    
  3. Then, using the Magento CLI, clean and flush the application caching

    php bin/magento cache:clean
    
    php bin/magento cache:flush
    

You should now be able to refresh the page and see the changes that you have made to the site.

Re-indexing Errors

Often we see issues where the Magento 2 cron to re-index encounters some kind of issue and is not able to fully complete. This leaves the application in a partially “indexed” state which, upon logging into the admin dashboard, you will be presented with an error alerting you to the application state. The quickest way to address this would be to issue the following command:

php bin/magento indexer:reindex

The proper way to address these issues is to make sure that the cron is able to run successfully. In a shared environment, there will be limitations to what you can control. To that end, we always recommend hosting your Magento 2 site(s) in a dedicated server instance. That way you can control the environment to a much better degree.

Changing Site Domain Name

If you have configured your site already and then find that you will need to change the domain name to something different you can certainly do so, but it will require a few changes in the admin dashboard.

  1. Log into your admin dashboard.

  2. Next, navigate to the Stores >> Configuration >> General >> Web. Select the Web button.

  3. Now select the Base URLs section, and replace the old domain name with the new domain name in the Base URLs field.

  4. Then, repeat for the **Base URLs (Secure).

  5. Finally, click the “Save Config” button at the top right.