Error 503 Backend Fetch Fails Varnish Cache Server


I installed magento 2.4 with digital oceans one click install

Its running in Ubuntu 18.04

I managed magento’s installation process and tried to install a theme after the process in which everything seemed to go right i tried to activate the theme from the admin panel. It said i was missing some permisions in var i updated some of the permisiones, tried clearing cache from ssh and reindexing and all of a sudden when trying to acces my website and admin panel y got this message 503 backend fetch message:

any clue about how i can fix this issue?

1 Like

As per my experience, there are 3 possible causes of the error
1. Length of cache tags used by Magento exceed Varnish’s default value
2. Wrong health_check.php location in Varnish config file
3. Maintenance.flag file generated by Magento 2
In your case, your site is a fresh site, you can try solution 3 first. If the error is still there, try solution 1&2
For detailed step by step to fix this error, you can refer this source

Fixing Magento 2 Error 503 Backend fetch failed with varnish cache

Normally, changing http_resp_hdr_len value will fix this error immediately
Hope this helps!

I’m afraid I haven’t used Varnish for years - Having had such a horrific experience with it during my Magento 1.7 days, I completely abandoned it. So, I don’t have any tips to offer here. Sorry.

Ok so i checked option 1 and 2 and everything is set up exactly as you suggest in my website. Tried the third option but i cant seem to fin the maintenance.flag file!! How can i locate it?

Hi Craig! Do you suggest i turn of varnish? if so what are the effects it will have on my magento? and if you do suggest this how can i disable it? Thanks

Don’t use Varnish is the quick answer, it’s very old tech. Use Litespeed caching.

As I don’t know how the stack was built on the Premade DigitalOcean Droplet, it’s hard to say if “turning it off” will simply break everything. As the stack might be configured to run through Varnish using reverse proxies.

I can’t condone Litespeed as I’ve never used it, however I definitely agree to avoid Varnish when possible - As the benefits don’t outweigh the pain. Or maybe it does if you have crazy high traffic like Amazon…

Hi @Andrea_Segura Did you sort it out finally? I have the same problem with mine droplet

No, havent figured out what’s going on i think i am gonna switch to a different server and see if that works. Ill keep you updated. Let me know if you find a fix

1 Like

Hi @Andrea_Segura I managed to get it working again!

What I done:

  1. Changed Varnish cache into Redis followed by this tutorial:

Very easy and quick, thanks to @digitalstartup!

  1. After Redis installation and enabling with Magento you won’t see page or admin because of the error.

You just need to set the mode: bin/magento deploy:mode:set developer

And switch back to production mode: bin/magento deploy:mode:set production

It will compile Magento again and deploy static content

  1. I also flushed and cleared the cache

bin/magento cache:flush
bin/magento cache:clean

And that’s it! You will be able to see your website again.

One thing. I didn’t check if step number 2 from above can sort out the problem before I switched to Redis. Maybe it also a way to sort it out? But with the Redis on board it’s no problem at all.


I’m surprised that worked, but happy it did. Normally, Varnish is integrated as a reverse proxy making it hard to detach from a typical setup.

Sadly i started all over again in a different server but next time i face the problem ill give it. a try, Thanks Raf!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.