We have successfully configured varnish in our magento website, it's working great. But the problem is varnish is not purging when we clear the cache either via admin panel or ssh command. We restart varnish server every time. We have also configured CDN (It may be reason for this cache issue). We have tried to set http_cache_hosts using the command

bin/magento setup:config:set --http-cache-hosts=xx.xx.xxx.xxx:6081

Also tried with ports 8080,6082

In our .vcl file

acl purge {

Above configurations is not at all working. We are missing something to make it work. Can anyone help on this?

4 Answers 4


1- check varnish port using :

sudo netstat -ltnp 

in my case it's port 80 enter image description here

2-Update cache host using

php bin/magento setup:config:set --http-cache-hosts=xx.xx.xxx.xxx:80

here i'm using port 80 ( varnish cache port )

3- check your vcl settings ( i'm using ubuntu under: /etc/varnish/default.vcl )

backend default {
    .host = "XX.XX.XX.XX";//here replace localhost with your ip

acl purge {
    "XX.XX.XX.XX";//here replace localhost with your ip

4-Now check if purge request received using

varnishlog -g request -q 'ReqMethod eq "PURGE"'

to send PURGE request go to the Admin, click SYSTEM > Tools > Cache Management, then click Flush Magento Cache at the top of the page.


using cmd

php bin/magento cache:flush 

Dont' forget to restart varnish after changes :

service varnish restart

php bin/magento setup:config:set --http-cache-hosts=

worked for us. BUT Varnish restart and cache flush wasn't enough. We needed to restart PHP-FPM as well


It is because of we missed to add our server ip address to the access list of varnish server. We can add our ip address also in the Access List field of Varnish configuration. If you use your own default.vcl in varnish server, it is enough to add magento server ip like below in default.vcl

acl purge {
    "xx.xx.xxx.xxx"; //Varnish server IP
    "yy.yy.yyy.yyy"; //Website server IP

Also make sure you have added varnish server ip in http_cache_hosts using below command

bin/magento setup:config:set --http-cache-hosts=xx.xx.xxx.xxx:80
  • Hiello sibhi how do we know varnish server ip and wbsite server ip? Mar 7, 2019 at 8:45

I have used only the following command with my exiting varnish magento 2 setup and its working fine,

php bin/magento setup:config:set --http-cache-hosts=,

My Ngnix http traffic forwarded to 8080 and varnish using 80 port. Following is my default.acl configuration,

backend default {
    .host = "localhost";
    .port = "80";
acl purge {

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.