You will sometimes see the error message: Error 503: Service Temporarily Unavailable in Magento 2 with the detailed message below.
Service Temporarily Unavailable the server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
This 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.
In this tutorial, we will learn the cause of this error and how to fix it, working for every Magento 2 version like 2.3.x and 2.4
Cause of the error
The error message is displayed when you access your Magento 2 store during Maintenance mode. You will not be able to access both the frontend and backend of your website during maintenance time.
The purpose of the maintenance mode is to prevent users from seeing any error messages when maintaining, upgrading, or reconfiguring your site. This is very important to protect your website from hackers or system exploit.
By default, Magento 2 system will automatically put your website into maintenance mode once it found .maintenance.flag
file in magento_root/var/folder
When you perform any actions like upgrading themes, extensions, or upgrade Magento 2 version, the system will automatically create .maintenance.flag
file in /var/
folder. Once the operation gets completed, the system will remove that file to turn off maintenance mode, and your site will operate normally.
However, sometimes the system will not automatically remove the file, thus show your website as if it’s still in maintenance mode.
Note: if the 503 error page show the message “Backend fetch failed with varnish cache” => Read this tutorial to learn How to fix Error 503 Backend fetch failed with varnish cache
Solution
Now you already know the cause of the issue, it’s easy to fix it now.
Solution 1: Manually remove the .maintenance.flag file
Step 1: Connect to your server using ssh and go to Magento2_root/var/
. Look for .maintenance.flag
, remove the file.
Step 2: Flush cache using this command
php bin/magento cache:flush
Or you can also flush cache via the Admin dashboard in System > Tool > Cache Management
Now refresh your website and the error page should be fixed
Solution 2: Run disable maintenance mode command
We can disable maintenance mode (which will also remove /var/.maintenance.flag
file) using this command:
php bin/magento maintenance:disable
Check if 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 site should be able to access normally
Solution 3: For Nginx users
Some users reported to me that they are running their Magento 2 on Nginx web server and even there’s no .maintenance.flag file in /var/ folder, their Magento 2 website is still not accessible with the error message
503 service temporarily unavailable nginx/1.13.12
So how we fix this?
If you are using Nginx and you see an error page like this:
This means the error is not related to Magento 2.
On Nginx, you will see this error if Nginx is not responding. Normally performing Nginx restart command should make things work again.
Run this command
sudo service nginx reload
Also, 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 website and it should work again!
Wrapping up
Solution 1 and Solution 2 work exactly the same way, feel free to use the method that you are comfortable with.
If you are using Magento 1.9, the maintenance.flag file is located in root folder rather that magento_root/var/ folder
I hope you will be able to fix Magento 2 Error 503 service temporarily unavailable after following my solution in this tutorial.
If you have any problems, feel free to drop a comment below. I will be happy to help!