Checking varnish configuration syntax

If you’ve updated your varnish server’s configuration, there doesn’t seem to be an equivalent of ‘apachectl configtest’ for it, but you can do :

varnishd -C -f /etc/varnish/default.vcl

If everything is correct, varnish will then dump out the generated configuration. Otherwise you’ll get an error message pointing you to a specific line number.






15 responses to “Checking varnish configuration syntax”

  1. guy Avatar

    This is kind of late, but thanks.

  2. Simon Rycroft Avatar

    It’s never too late to say thank you. This was exactly what I was looking for.

  3. Martin Garcia Avatar

    I was looking for logs, but this helped me right away, THANKS!

  4. Dan Miller Avatar
    Dan Miller

    Sometimes it’s the simple things that make life easier. Varnishlogs aren’t what you’d expect so this is a life-saver (especially after an upgrade)

  5. Monir Avatar

    Yep, very helpful command, I was just pulling my hair to find where is the syntax error. Just run the command and found the remedy!

    Thank you!

  6. Herlon Aguiar Avatar
    Herlon Aguiar

    Thanks !

  7. Rand Thacker Avatar
    Rand Thacker

    Thanks! Just what I was looking for

  8. Gwyneth Llewelyn Avatar

    It’s 2017, but your solution still works like a charm! Thank you very much for posting it ๐Ÿ™‚

  9. Jonathan Avatar

    Brilliant. Thank you very much. Just the command I was hoping to find. Cheers. I knew there must be some way to test varnish, but hadn’t figured out what it was.

  10. Avatar

    August 2018 and still a life-saver! ๐Ÿ™‚

  11. Christian Avatar

    thanks from 2019

  12. Uwe Trotzek Avatar
    Uwe Trotzek

    Awesome, thanks! ๐Ÿ™‚

  13. Slava Avatar

    Thanks from 2021 ๐Ÿ™‚ Worked.

  14. w3bd3v Avatar

    Some “guy” in 2012, “This is kind of late…”

    Cut to me in 2021 still referring to this page every few months because I need to check my varnish changes. ๐Ÿ™‚

  15. Antony Avatar

    and because I got tired of having my console flying 2k lines (and as w3bd3v having to come back here every now and again) I end up creating an alias

    alias testnreloadvarnish=’error=$(varnishd -C -f /etc/varnish/default.vcl 2>&1) && (echo “default.vcl OK. Reloading varnish…” && systemctl reload varnish && echo “Done.”) || echo “$error”‘

Leave a Reply

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