Varnish: VCL version declaration missing Update your VCL to Version 4 syntax

Today I installed latest version of varnish on a new server and configured it manually. I tried to start it but it was failing. So I did a configuration file test and it gave below error.

# varnishd -C -f /etc/varnish/default.vcl
Message from VCC-compiler:
VCL version declaration missing
Update your VCL to Version 4 syntax, and add
        vcl 4.0;
on the first line the VCL files.
('input' Line 1 Pos 1)
backend default {
#######----------

Running VCC-compiler failed, exit 1

VCL compilation failed

If you read the error carefully then it says that the vcl-compiler requires additional line “vcl 4.0;” added at the top of the configuration file. This happened because Varnish 3.0 configuration syntax is not fully compatible with varnish 4.0. You will have to make a few simple changes to make it work.

vcl 4.0;
backend default {
        .host="XX.XX.XX.XX";
        .port="8082";
}

So after adding the line. The varnish started running perfectly.

root@ [~]# /etc/init.d/varnish restart
Stopping Varnish Cache:                                    [  OK  ]
Starting Varnish Cache: 0
                                                           [  OK  ]
root@ [~]#