Varnish error for failed backend

Geoff Simmons geoff at
Sat Mar 31 14:10:15 UTC 2018

On 03/31/2018 02:36 PM, Danila Vershinin wrote:
> However, I’m also interested how can we distinguish backend errors
> while using grace mode and failed probe.
> Suppose that you have configured grace mode and a health check
> against homepage. And homepage fails with 500.
> The backend is marked as sick, then synthetic response (guru
> meditation) is delivered from vcl_backend_error with resp.status
> pre-filled to 503.
> So there seems to be no way to do the same conditional error display
> in that case?

Oh I'm sorry, I think I may have misunderstood your question.

I assume in this scenario that Varnish never got a valid response that
could be cached -- otherwise, the cached object could have been
delivered while it's still in grace.

As long as the health probe is failing, Varnish doesn't attempt any
fetch in response to a client request at all. Varnish makes a note of
the backend sick state, and then any request meant for that backend goes
right to the 503 response and vcl_backend_error, logging FetchError=="no
backend connection". There's no attempt to re-use or initiate a network
connection, let alone forward a request, it just becomes 503 and that's
it, until the health probe goes back to healthy.

So the 503 you get in that situation is only indirectly related to the
500 health probe response -- the health probes see the 500, running in
their own threads and independent of any request/response traffic.

That means that you can't establish a relation between the 503 fetch
failure and the 500 health probe response in VCL. What you can do is
look at std.healthy(backend), something like:

    import std;

    if (!std.healthy(mybackend)) {
        set resp.body = "..." + "... because the backend is sick ...";

And of course there's the log -- FetchError=="no backend connection" and
the Backend_health entries.

Hope that helped a little better this time,
** * * UPLEX - Nils Goroll Systemoptimierung

Scheffelstraße 32
22301 Hamburg

Tel +49 40 2880 5731
Mob +49 176 636 90917
Fax +49 40 42949753

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the varnish-misc mailing list