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 an independent software developer ⌨️ & Linux sysadmin 👨‍💻, a general web geek & public speaker. Currently working on DNS Spy & Oh Dear! Follow me on Twitter as @mattiasgeniar 🐦.

🔥 If you're stuck with a technical problem, I'm available for hire to help you fix it!

Share this post

Did you like this post? Help me share it on social media! Thanks. 🤗

Have feedback?

New comments have been disabled on this blog, existing comments will remain as-is. Want to give feedback? Is there a mistake in the post?

Send me a tweet on @mattiasgeniar!


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 :-) )

Shawkat Alam Wednesday, July 10, 2019 at 13:25 -

After 2 Days of frustration, I found your post useful