Magento error 503: The cause and how to fix it in Magento 2

Magento error 503 means that the server is not available at the instant. This error may happen because the server is under maintenance mode or it is busy. The question is, how can you deal with this problem? This article introduces some easy methods to fix it. This solution works effectively for every Magento 2 version like 2.3.x and 2.4.

What is the Magento error 503?

magento-error-503

Magento error 503 typically means the server is not available and under maintenance mode. If you or your visitors are getting error 503 – service temporarily unavailable, it means that there is something wrong with your site. In another way, it means that the server is not available to fulfill the request at the moment due to it may not be responding. You will likely get the below message.

  • server can’t handle a request instantly
  • server temporarily unavailable
  • maintenance mode is permitted
  • The server is busy
  • The server is overloaded

Magento error 503 is one of the most common errors in Magento 2. However, the error message is generic and does not provide a solution for fixing this error. Besides, if you know how to solve Magento error 503 in Magento 1, your skills won’t help you bring Magento 2 back to life, so check this tutorial.

Cause of the Magento error 503

Let’s find out why Magento 2 Service Temporarily Unavailable error occurs in your Magento 2 store. Usually, the error message appears when you access your website during Maintenance mode. You will not be able to access both the frontend and backend of your Magento 2 store during maintenance time.

The aim of the maintenance mode is to prevent visitors from seeing any error messages when maintaining, upgrading, or reconfiguring your website. This is a crucial task to protect your website from hackers or system exploit.

By default, Magento 2 system will automatically put your site into maintenance mode when it found .maintenance.flag file in magento_root/var/folder

maintenance-flag-error-503

Moreover, when you perform any tasks like upgrading themes, modules, or upgrade versions, the Magento will automatically generate .maintenance.flag files in /var/ folder. Once the actions get completed, the system will remove that file to turn off maintenance mode, and your Magento 2 site will work normally. However, sometimes the system will not automatically remove the file, thus your website appears error 503.

Now, we know the reasons for error 503 – Service Temporarily Unavailable for Magneto 2, it is time to get back to our main topic today, we will provide you three solutions to solve Magento error 503 after the upgrade right below.

How to resolve this Magento error 503?

Method 1: Disabling the maintenance mode

This is the most common and easy method which everyone should try as the first option.

  • Firstly, you go to the Magento root folder to delete the file var/.maintenance.flag
  • After that, you refresh Magento 2 cache from php bin/magento cache:flush or via the Admin Panel
  • Check the error log if you see a message saying “Exception printing is disabled by default for security reasons.”
  • If you see an error like “Please Upgrade your database”, run php bin/magento setup: upgrade from the root directory.

Note: The maintenance mode file differs for Magento 1 from Magento 2.

  • Magento 1.x: Delete maintenance.flag file from Magento root folder
  • Magento 2.x: Delete .maintenance.flag file from the folder [Magento root folder]/var.

Method 2: For Nginx users

There are some people running their Magento 2 on the Nginx web server and there’s no .maintenance.flag file in /var/ folder, their online store is still not accessible with the error message

503 service temporarily unavailable
nginx/1.13.12

If you are using Nginx and you will see an error page like this:

magento-error-503-service-unavailable
  • That means the error is not related to Magento 2.
  • On Nginx, you will see this error if Nginx is not responding. Usually performing Nginx restart command should make things work again.
  • Use the following command
sudo service nginx reload
  • At the same time, you restart php-fpm if it’s installed on your server
service php7.1-fpm restart
  • Repace php7.1-fpm with your php-fpm version.
  • Now reload your site and it should work again!

Method 3: Run disable maintenance mode command

  • We can disable maintenance mode (which will also remove /var/.maintenance.flag file) appling  this command:
php bin/magento maintenance:disable
  • You can check if the maintenance mode is disabled
php bin/magento maintenance:status
  • Sample output
# php bin/magento maintenance:status
Status: maintenance mode is not active
List of exempt IP-addresses: none
  • Now, your Magento 2 website should be able to access normally

Conclusion

When you’ve done all the above steps, you can deal with Magento error 503 – Service temporarily unavailable. No more errors in your Magento 2 store so that your customers can enjoy your services without any difficulty. The solution is presented in the most simple way possible, however, if you find anything unclear about these solutions or any other procedure related to this method, then feel free to contact our Support Team. We’re very pleased to support you.Thanks for your time!

Besides, if you are looking out for a cost effective Magento package for your eCommerce store, then look nowhere other than Magesolution. We not only offer an affordable Magento Development Package for all size and budget but also ensure that it helps your online business grow and sustain. Contact us for a free consultation!