Error 503 backend fetch failed Magento 2 causing trouble?
At Bobcares, we offer solutions for every query, big and small, as a part of our Server Management Service.
Let’s take a look at how our Support Team recently helped a customer with Error 503 backend fetch failed in Magento 2.
About “Error 503 Backend Fetch failed” in Magento 2
Magneto 2 can be described as a free eCommerce platform that helps small businesses with a digital commerce solution that is flexible and helps boost online sales. It offers several features that may make it difficult in some cases.
In fact, Error 503 Backend Fetch failed with Varnish cache error is a common error faced by many. Fortunately, our Support Team has come up with this guide to help you out of this particular problem.
Causes behind Error 503 Backend Fetch failed
Before we dive into the solution, let’s take a look at the reasons behind this error:
- Length of cache tags exceeds Varnish’s default value.
- Inaccurate health_check.php location in Varnish config file
- Maintenance.flag file generation by Magneto 2
Each of these causes requires a different strategy in order to resolve the error. Our Support Techs have a solution for each of these causes.
Option 1: Length of cache tags exceeds Varnish’s default value
If the business has a large number of products, the error may arise due to the length of the cache tags exceeding the default value of Varnish. According to our Support Team, Varnish offers a default value of 8192 bytes.
Moreover, this is a clear indication that a catalog of more than 400 products can lead to an error.
According to our Support Techs, we can resolve this issue by changing the http_resp_hdr_len value in the Varnish config file. We can find the configuration file at these locations:
For Ubuntu:
: /etc/default/varnish
In CentOS 6:
/etc/sysconfig/varnish
For CentOS 7:
/etc/varnish/varnish.params
Once we locate the file, we can edit it using a text editor. We will find the http_resp_hdr_len value located at line 101, immediately after the thread_pool_max value.
For instance:
-p http_resp_hdr_len=8192 \
We have to change it to a larger value. For example, 70000 bytes is apt for a catalog of 3000+ products.
After that, we have to change http_resp_size to a value that corresponds tot he new http_resp_hdr_len. For example, if we increase http_resp_hdr_len to 70000, then we will increase http_resp_hdr_len to 10000 in this scenario.
Hence, after the modification, it will look like this:
-p http_resp_hdr_len=70000 \ -p http_resp_size=100000 \
Finally, we will save the changes made and restart Magneto for the new changes to take effect.
Option 2: Inaccurate health_check.php location in Varnish config file
If the error is due to an inaccurate health_check.php file location in Varnish, we need to rectify this issue. In fact, this particular file can be found at /pub/health_check.php by default in Varnish.
In order to resolve the error, we will open the Varnish configuration file located at /etc/varnish/default.vcl and find the following lines:
.probe = { .url = "/pub/health_check.php";
We will then change it the following:
.probe = { .url = "/health_check.php";
After that, we will head to the ginx.conf.sample file located in the Magento 2 root folder and find the following lines:
location ~ (index|get|static|report|404|503)\.php$ {
Then, we have to add health_check as seen below:
location ~ (index|get|static|report|404|503|health_check)\.php$ {
Finally, we will save the changes and restart nginx and Varnish to allow the changes to take effect.
Option 3: Maintenance.flag file generation by Magneto 2
Another undue reason behind the Error 503 is the var/.maintenance file. It is generated by Magneto 2 during installation of new extensions or themes, maintenance, up-gradation, or even during reconfiguration of the site.
Our Support Techs recommend opening the file manager and either renaming or removing the maintenance.flag file and refreshing the website.
[Looking for assistance with another query? We are available 24/7.]
Conclusion
In short, the skilled Support Engineers at Bobcares demonstrated how to resolve the error 503 backend fetch failed in Magento 2.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
My varnish.params file only has 37 lines and no references to http_resp_hdr_len ?
Hi,
Please contact our support team via live chat(click on the icon at right-bottom)