Magento 2 503 Backend Fetch Failed

In Magento 2, this error is caused because the length of cache tags is more than 8192 characters. You can fix this error by increasing http_resp_hdr_len value in varnish configuration file.

I followed this tutorial https://magentip.com/magento-2-error-503-backend-fetch-failed-with-varnish-cache/ and successfully fixed that error.

Step 1: Depend on your OS, navigate to:

Ubuntu: /etc/default/varnish

CentOS 6.x: /etc/sysconfig/varnish

CentOS 7.x: /etc/varnish/varnish.params

Step 2:

Edit config file and add the following line:

-p http_resp_hdr_len=42000

For example:

DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
         -f ${VARNISH_VCL_CONF} \
         -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
         -t ${VARNISH_TTL} \
         -p thread_pool_min=${VARNISH_MIN_THREADS} \
         -p thread_pool_max=${VARNISH_MAX_THREADS} \
         -p http_resp_hdr_len=42000 \

Save file and restart your server. The error should be gone.