Troubleshooting 503 (Backend Fetch Failed) errors
If the length of cache tags used by Magento exceed Varnish’s default of 8192 bytes, you can see HTTP 503 (Backend Fetch Failed) errors in the browser. The errors might display similar to the following:
1
2
Error 503 Backend fetch failed
Backend fetch failed
To resolve this issue, increase the default value of the http_resp_hdr_len
parameter in your Varnish configuration file. The http_resp_hdr_len
parameter specifies the max header length within the total default response size of 32768 bytes.
If the http_resp_hdr_len
value exceeds 32768 bytes, you must also increase the default response size using the http_resp_size
parameter.
-
As a user with
root
privileges, open your Vanish configuration file in a text editor:- CentOS 6:
/etc/sysconfig/varnish
- CentOS 7:
/etc/varnish/varnish.params
- Debian:
/etc/default/varnish
- Ubuntu:
/etc/default/varnish
- CentOS 6:
- Search for the
http_resp_hdr_len
parameter. - If the parameter doesn’t exist, add it after
thread_pool_max
. -
Set
http_resp_hdr_len
to a value equal to the product count of your largest category multiplied by 21. (Each product tag is about 21 characters in length.)For example, setting the value to 65536 bytes should work if your largest category has 3,000 products:
1
-p http_resp_hdr_len=65536 \
-
Set the
http_resp_size
to a value that accommodates the increased response header length.For example, using the sum of the increased header length and default response size is a good starting point (e.g., 65536 + 32768 = 98304):
1
-p http_resp_size=98304 \
A snippet follows:
1 2 3 4 5 6 7 8 9 10
# DAEMON_OPTS is used by the init script. DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \ -f ${VARNISH_VCL_CONF} \ -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \ -p thread_pool_min=${VARNISH_MIN_THREADS} \ -p thread_pool_max=${VARNISH_MAX_THREADS} \ -p http_resp_hdr_len=65536 \ -p http_resp_size=98304 \ -S ${VARNISH_SECRET_FILE} \ -s ${VARNISH_STORAGE}"