Debug Varnish 4.x on systemd That Fails to Start

Mattias Geniar, Sunday, March 15, 2015 - last modified: Wednesday, July 27, 2016

So you're stuck in systemctl start varnish, now what?

Well, by default, systemd won't tell you much.

$ systemctl start varnish
Job for varnish.service failed. See 'systemctl status varnish.service' and 'journalctl -xn' for details.

View the status of the service:

$  systemctl status varnish
varnish.service - Varnish a high-perfomance HTTP accelerator
   Loaded: loaded (/usr/lib/systemd/system/varnish.service; enabled)
   Active: failed (Result: exit-code) since Sun 2015-03-15 21:07:41 CET; 15s ago
  Process: 10049 ExecStartPre=/usr/sbin/varnishd -C -f $VARNISH_VCL_CONF (code=exited, status=0/SUCCESS)
 Main PID: 6187 (code=exited, status=0/SUCCESS) varnishd[10049]: .miss_func = VGC_function_vcl_miss, varnishd[10049]: .hit_func = VGC_function_vcl_hit, varnishd[10049]: .deliver_func = VGC_function_vcl_deliver, varnishd[10049]: .synth_func = VGC_function_vcl_synth, varnishd[10049]: .backend_fetch_func = VGC_function_vcl_backend_fetch, varnishd[10049]: .backend_response_func = VGC_function_vcl_backend_response, varnishd[10049]: .backend_error_func = VGC_function_vcl_backend_error, varnishd[10049]: .init_func = VGC_function_vcl_init, varnishd[10049]: .fini_func = VGC_function_vcl_fini, varnishd[10049]: };

It'll show the message that Varnish failed to start, and it will show the last 10 lines of output the program sent to stdout/stderr. But in Varnish' case, that's just the compiled VCL and it won't actually tell you the error.

To start, test the syntax of your Varnish 4 VCL file.

$ varnishd -d -f /etc/varnish/default.vcl
Varnish Cache CLI 1.0

If you see a "Varnish Cache CLI", your VCL compiled and is working. That means the problem could be in the way systemd starts its service.

$ grep systemd /var/log/messages
Mar 15 21:07:41 lb01 systemd: Starting Varnish a high-perfomance HTTP accelerator...
Mar 15 21:07:41 lb01 systemd: varnish.service: control process exited, code=exited status=2
Mar 15 21:07:41 lb01 systemd: Failed to start Varnish a high-perfomance HTTP accelerator.
Mar 15 21:07:41 lb01 systemd: Unit varnish.service entered failed state.

So in this case, systemd failed to start the service with my requested parameters. Check your varnish.service in /usr/lib/systemd/system/varnish.service file for any typos or mis-configured environment variables and try again!

Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek, public speaker and podcaster. Currently working on DNS Spy. Follow me on Twitter as @mattiasgeniar.

I respect your privacy and you won't get spam. Ever.
Just a weekly newsletter about Linux and open source.

SysCast podcast

In the SysCast podcast I talk about Linux & open source projects, interview sysadmins or developers and discuss web-related technologies. A show by and for geeks!

cron.weekly newsletter

A weekly newsletter - delivered every Sunday - for Linux sysadmins and open source users. It helps keeps you informed about open source projects, Linux guides & tutorials and the latest news.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!


stuartm Wednesday, May 13, 2015 at 02:26

Thanks – this post and your related post ( helped me troubleshoot an issue with Varnish 4 on Debian 8. The Varnish service was starting okay, but it wasn’t using my settings in /etc/default/varnish. From your posts I realised that the varnish.service script was not referencing any parameters files (not even the varnish.params you suggested). This is on a clean build of Debian 8 and is reproducible.

(btw – I added your site to my ad-blocker whitelist :-) )


    Mattias Geniar Wednesday, May 13, 2015 at 20:02

    Glad to hear it helped and thanks for whitelisting! :-)


Leave a Reply

Your email address will not be published. Required fields are marked *