error 503 backend fetch failed
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
We can change the limitation of Varnish by increasing the value http_resp_hdr_len in Varnish configuration file.
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.
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.
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.
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:
- Ubuntu: /etc/default/varnish
- CentOS 6.x: /etc/sysconfig/varnish
- CentOS 7.x: /etc/varnish/varnish.params
Login as root, navigate to the following path depending on your OS and edit Varnish configuarion file with a text editor:
When working in Magento admin backend section, sometimes you will see the error message
# # DAEMON_OPTS is used by the init script. If you add or remove options, make
# # sure you update this section, too.
-u varnish -g varnish
Follow our instruction in this tutorial to learn on how to fix error 503 backend fetch failed.
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)