Magento 2 error 503 backend fetch failed – How to fix

3

When working in Magento admin backend section, sometimes you will see the error message

Magento error 503 backend fetch failed

Normally, you can hit F5 or refresh button of the browser to get rid of this error but it will appear again if you don’t fix it completely. In some case, this is a permanent error and even you hit refresh, the error will not go away.

Follow our instruction in this tutorial to learn on how to fix  error 503 backend fetch failed. 

Cause of the error

As you know, Magento 2 uses Varnish by default and Varnish limits 8192 characters for the length of any element using Varnish, such as: cache tags, CLI commands… With Magento 2,  this error is caused because the length of cache tags is more than 8192 characters.

Solution

We can change the limitation of Varnish by increasing the value  http_resp_hdr_len  in Varnish configuration file.

Step 1:

Login as root, navigate to the following path depending on your OS and edit Varnish configuarion file with a text editor:

  • Ubuntu: /etc/default/varnish
  • CentOS 6.x: /etc/sysconfig/varnish
  • CentOS 7.x: /etc/varnish/varnish.params

Step 2:

Look for http_resp_hdr_len  value in this file. If you can’t find it, then add that value after  thread_pool_max  value as 64000 (line 101) as below:

For example:

Save file and restart your server to apply change (*Note: if you are using hosting without permission to change the value, ask your hosting support staff, we suggest using the hosting in this review for a quick support)

Explanation: The value of http_resp_hdr_len  should be set to a number that is equal to the number of your products in your biggest category multiplied by 21 (estimated number of product tag character). For example, your biggest category has 2000 products, each product tag contain 21 characters, then the http_resp_hdr_len  value should be: 2000*21 = 42000

Updated solution

When solving this problem on our clients’ website, sometimes we need to downgrade php version from PHP7.0 to 5.6, that will also fix the problem.

Magento 2 error 503 backend fetch failed – How to fix
5 (100%) 2 votes

Share.

About Author

Daniel is a Magento developer with 5 years of experience with customizing Magento extensions, Magento templates. He's main author at Magento explorer

3 Comments

  1. I installed Magento 2 using the Bitnami image. I cannot find “/etc/default/varnish”. Any idea how to find out where the varnish config is stored?

Leave A Reply