Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Error 503 backend fetch failed Magento 2 | Causes & Solutions

by | Dec 5, 2021

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.

GET STARTED

2 Comments

  1. Fran

    My varnish.params file only has 37 lines and no references to http_resp_hdr_len ?

    Reply
    • Hiba Razak

      Hi,
      Please contact our support team via live chat(click on the icon at right-bottom)

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF