Search code examples
varnish

varnish service has failed to start


Trying to install varnish on cpanel+cloudlinux VPS but can't start the software. varnish.service has failed.

$varnishd -V varnishd 

(varnish-6.0.8 revision 97e54ada6ac578af332e52b44d2038bb4fa4cd4a) Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2020 Varnish Software AS

try to start varnish...

$systemctl start varnish

Job for varnish.service failed because the control process exited with error code. See "systemctl status varnish.service" and "journalctl -xe" for details.

my apache is listed on port 8080...

$netstat -pnltu

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:587             0.0.0.0:*               LISTEN      656/exim
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      1272/memcached
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN      1275/dovecot
tcp        0      0 0.0.0.0:2095            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp        0      0 127.0.0.1:783           0.0.0.0:*               LISTEN      1499/perl
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      1275/dovecot
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      830454/httpd
tcp        0      0 0.0.0.0:2096            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp        0      0 0.0.0.0:465             0.0.0.0:*               LISTEN      656/exim
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      1290/pdns_server
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      1276/pure-ftpd (SER
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      656/exim
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      1290/pdns_server
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      830454/httpd
tcp        0      0 0.0.0.0:38908           0.0.0.0:*               LISTEN      1225059/checkstatus
tcp        0      0 0.0.0.0:2077            0.0.0.0:*               LISTEN      2364/cpdavd - accep
tcp        0      0 0.0.0.0:2078            0.0.0.0:*               LISTEN      2364/cpdavd - accep
tcp        0      0 0.0.0.0:2079            0.0.0.0:*               LISTEN      2364/cpdavd - accep
tcp        0      0 0.0.0.0:2080            0.0.0.0:*               LISTEN      2364/cpdavd - accep
tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      1275/dovecot
tcp        0      0 0.0.0.0:2082            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp        0      0 0.0.0.0:2083            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp        0      0 127.0.0.1:579           0.0.0.0:*               LISTEN      1939/cPhulkd - proc
tcp        0      0 0.0.0.0:995             0.0.0.0:*               LISTEN      1275/dovecot
tcp        0      0 0.0.0.0:2086            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp        0      0 0.0.0.0:36454           0.0.0.0:*               LISTEN      5439/sshd
tcp        0      0 0.0.0.0:2087            0.0.0.0:*               LISTEN      337953/cpsrvd
tcp6       0      0 :::3306                 :::*                    LISTEN      1215674/mysqld
tcp6       0      0 :::587                  :::*                    LISTEN      656/exim
tcp6       0      0 :::465                  :::*                    LISTEN      656/exim
tcp6       0      0 :::53                   :::*                    LISTEN      1290/pdns_server
tcp6       0      0 :::21                   :::*                    LISTEN      1276/pure-ftpd (SER
tcp6       0      0 :::4949                 :::*                    LISTEN      749/perl
tcp6       0      0 :::25                   :::*                    LISTEN      656/exim
tcp6       0      0 :::36454                :::*                    LISTEN      5439/sshd
udp        0      0 0.0.0.0:53              0.0.0.0:*                           1290/pdns_server
udp        0      0 127.0.0.1:323           0.0.0.0:*                           571/chronyd
udp        0      0 127.0.0.1:11211         0.0.0.0:*                           1272/memcached
udp6       0      0 :::53                   :::*                                1290/pdns_server
udp6       0      0 ::1:323                 :::*                                571/chronyd

mY Varnish status...

$systemctl status varnish.service

varnish.service - Varnish Cache, a high-performance HTTP accelerator Loaded: loaded (/usr/lib/systemd/system/varnish.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Fri 2021-10-08 08:32:43 IDT; 5min ago Process: 1498287 ExecStart=/usr/sbin/varnishd -a :80 -a localhost:8443,PROXY -p feature=+http2 -f /etc/varnish/default.vcl -s malloc,256m (code=exited, status=255)

and My /etc/varnish/default.vcl file...

$cat /etc/varnish/default.vcl

backend default { .host = "127.0.0.1"; .port = "8080";}

$journalctl -xe

Oct 11 18:54:19 server1. varnishd[1765617]: Update your VCL to Version 4 Oct 11 18:54:19 server1. varnishd[1765617]: vcl 4.1; Oct 11 18:54:19 server1. varnishd[1765617]: on the first line of the VCL Oct 11 18:54:19 server1. varnishd[1765617]: ('/etc/varnish/default.vcl' Oct 11 18:54:19 server1. varnishd[1765617]: backend default { Oct 11 18:54:19 server1. varnishd[1765617]: #######---------- Oct 11 18:54:19 server1. varnishd[1765617]: Running VCC-compiler failed, Oct 11 18:54:19 server1. varnishd[1765617]: VCL compilation failed Oct 11 18:54:19 server1. systemd[1]: varnish.service: control process ex Oct 11 18:54:19 server1. systemd[1]: Failed to start Varnish Cache, a hi Subject: Unit varnish.service has failed Defined-By: systemd Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel Unit varnish.service has failed. The result is failed. Oct 11 18:54:19 server1. systemd[1]: Unit varnish.service entered failed Oct 11 18:54:19 server1. systemd[1]: varnish.service failed. Oct 11 18:54:19 server1. polkitd[533]: Unregistered Authentication Agent Oct 11 18:54:24 server1. dovecot[506582]: lmtp(1764533): Connect from lo Oct 11 18:54:24 server1. dovecot[506582]: lmtp(develop@wordwpressplugins Oct 11 18:54:24 server1. dovecot[506582]: lmtp(1764533): Disconnect from

Thank u


Solution

  • My assumption

    The following error message stands out:

    Oct 11 18:54:19 server1. varnishd[1765617]: Update your VCL to Version 4
    

    It refers to the fact that you didn't specify a VCL version in your VCL file.

    My tests return a different error:

    However, when it test it with an AWS instance that runs https://aws.amazon.com/marketplace/pp/prodview-ptcusqlqcvvki?sr=0-2&ref_=beagle&applicationId=AWSMPContessa, I get the following error:

    Oct 12 08:06:33  varnishd[44646]: Error:
    Oct 12 08:06:33  varnishd[44646]: Message from VCC-compiler:
    Oct 12 08:06:33  varnishd[44646]: VCL version declaration missing
    Oct 12 08:06:33  varnishd[44646]: Update your VCL to Version 4 syntax, and add
    Oct 12 08:06:33  varnishd[44646]:         vcl 4.1;
    Oct 12 08:06:33  varnishd[44646]: on the first line of the VCL files.
    Oct 12 08:06:33  varnishd[44646]: ('/etc/varnish/default.vcl' Line 1 Pos 1)
    Oct 12 08:06:33  varnishd[44646]: backend default {
    Oct 12 08:06:33  varnishd[44646]: #######----------
    Oct 12 08:06:33  varnishd[44646]: Running VCC-compiler failed, exited with 2
    Oct 12 08:06:33  varnishd[44646]: VCL compilation failed
    Oct 12 08:06:33  systemd[1]: varnish.service: Control process exited, code=exited status=255
    Oct 12 08:06:33  systemd[1]: varnish.service: Failed with result 'exit-code'.
    

    As you can see, my CloudLinux 8 cPanel instance on AWS returns a more specific error message.

    How to fix

    Since Varnish 4, a VCL version label was introduced. You need to specify it at the start of your VCL file.

    Here's how I would refactor your example:

    vcl 4.1;
    
    backend default { 
        .host = "127.0.0.1"; 
        .port = "8080";
    }
    

    I'm using vcl 4.1; as the VCL version label because you are running Varnish 6. Earlier versions of Varnish only support vcl 4.0;