Skip to content

Varnish Cache won’t clear on Magento 2.4.2

I’m running Magento 2.4.2 and have recently added Varnish to it. The site also has Cloudflare in front of it.

The server is running Plesk (Ubuntu) and Varnish is running in Docker within Plesk.

I’ve followed https://dx3webs.com/configure-varnish-for-magento-2-on-plesk/ to the letter and the site is now using Varnish but I cannot get Varnish to flush whene doing a Magento Cache Flush.

I’ve added http_cache_hosts with the site ip and port 80 but no success.

My env.php does have cache rules in it, pointing at Redis, which is what I used to use before Varnish but removing those doesn’t help.

The hosting config is Nginx and apache but nothing I do gets Varnish to clear.

The only way to refresh it currently is to restart Varnish everytime I make a change to content.

I’m guessing I need to remove the sections from env.php that refer to
‘cache’ => [
and
‘page_cache’ => [

I have added (ip redacted) the following to env.php

‘http_cache_hosts’ => [
[
‘host’ => ‘XX.XX.XX.XXX’,
‘port’ => ’80’
]
]

but I can’t see what else I can add / remove / configure to get flush to clear Varnish.

Any help would be much appreciated.