Getting 503 Fetch Failed in M2. I've redis and Varnish server running along with Nginx my varnishlog says
my default.vcl
vcl 4.0;
import std;
# The minimal Varnish version is 4.0
# For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https'
backend default {
.host = "localhost";
.port = "8080";
}
acl purge {
"localhost";
}
sub vcl_recv {
if (req.method == "PURGE") {
if (client.ip !~ purge) {
return (synth(405, "Method not allowed"));
}
if (!req.http.X-Magento-Tags-Pattern) {
return (synth(400, "X-Magento-Tags-Pattern header required"));
}
ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern);
return (synth(200, "Purged"));
}
VARNISH LOG
* << Request >> 32838
- Begin req 32837 rxreq
- Timestamp Start: 1468597956.246653 0.000000 0.000000
- Timestamp Req: 1468597956.246653 0.000000 0.000000
- ReqStart 192.168.1.1 19182
- ReqMethod GET
- ReqURL /robots.txt
- ReqProtocol HTTP/1.1
- ReqHeader Cache-Control: no-cache
- ReqHeader Connection: Keep-Alive
- ReqHeader Pragma: no-cache
- ReqHeader Accept: */*
- ReqHeader Accept-Encoding:
- ReqHeader From: bingbot(at)microsoft.com
- ReqHeader Host: www.salon-towels.com
- ReqHeader User-Agent: Mozilla/5.0 (compatible; bingbot/2.0; +http://www
- ReqHeader X-Forwarded-For: 192.168.1.1
- VCL_call RECV
- ReqURL /robots.txt
- VCL_return hash
- ReqUnset Accept-Encoding:
- VCL_call HASH
- VCL_return lookup
- VCL_call MISS
- VCL_return fetch
- Link bereq 32839 fetch
- Timestamp Fetch: 1468597961.245436 4.998783 4.998783
- RespProtocol HTTP/1.1
- RespStatus 503
- RespReason Backend fetch failed
- RespHeader Date: Fri, 15 Jul 2016 15:52:41 GMT
- RespHeader Server: Varnish
- RespHeader Content-Type: text/html; charset=utf-8
- RespHeader Retry-After: 5
- RespHeader X-Varnish: 32838
- RespHeader Age: 0
- RespHeader Via: 1.1 varnish-v4
- VCL_call DELIVER
- RespUnset Age: 0
- RespUnset Server: Varnish
- RespUnset X-Varnish: 32838
- RespUnset Via: 1.1 varnish-v4
- VCL_return deliver
- Timestamp Process: 1468597961.245516 4.998863 0.000080
- RespHeader Content-Length: 282
- Debug "RES_MODE 2"
- RespHeader Connection: keep-alive
- Timestamp Resp: 1468597961.245621 4.998968 0.000105
- ReqAcct 272 0 272 175 282 457
- End
* << Session >> 32837
- Begin sess 0 HTTP/1
- SessOpen 192.168.1.1 19182 :80 192.168.1.34 80 1468597956.246550 15
- Link req 32838 rxreq
- SessClose REM_CLOSE 5.082
Best Answer
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:
For example:
Save file and restart your server. The error should be gone.