Varnish made some changes in how you clear the cache in Varnish 3. Hence the confusing title. However, it’s simple to clear the cache now, by using the “ban” command.

[:$] varnishadm -T 127.0.0.1:6089 ban.url /index.html

There are a few things you should be aware of. Varnish can run on different ports than 6089, so if you receive the following error:

Connection failed

It’s either because the IP address or the port that Varnish is listening on isn’t correct. A simple method to check this is to use the netstat command.

[:$] netstat -plnt
tcp 0 0 192.168.1.1:2222 0.0.0.0:* LISTEN 14142/varnishd

Here we see varnish is listening on the IP address 192.168.1.1 and port 2222.

So to clear/purge/ban the cache we just modify our command line command as follows

[:$] varnishadm -T 192.168.1.1:2222 ban.url /index.html

And you’re done!

Get actionable training and tech advice

We'll email you our latest articles up to once per week.