Have enabled varnish for magento 2 and all the static page, PDP and PLP pages working properly. But some time the checkout flow shows 503 error. If i refresh the page it loads properly.

2 Answers 2


I have included following code in default.vcl file at the bottom. Now not getting 503 on checkout page.


 sub vcl_backend_error {
         if (beresp.status >= 500 && bereq.retries < 7) { # retry for 7 times
           set beresp.http.Content-Type = "text/html; charset=utf-8";
           synthetic( {"503 error!"} );
           return (deliver);

on this you can set the retry count to 5 or more. The default retry count is 4 in varnish configuration.


Run varnishlog -g request -q "RespStatus == 503" and have a look if the Varnish logs provide any insight on the reason why the failure happens.

If you can't figure it out by yourself, please attach the full log transaction to your original question and I'll try to help you out.

See also https://www.varnish-software.com/developers/tutorials/troubleshooting-varnish/ for more Varnish troubleshooting tips & tricks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.