Troubleshooting Varnish Cache 503 Guru Meditation Error

varnish cache errorIf you use Varnish Cache on your website or are visiting a website that caches content with Varnish Cache, chances are at some point you will come across the Varnish Cache server error: Error 503 Service Unavailable / Guru Meditation with an XID number. A 503 error means that the web server trying to be reached is unavailable - this could be because it is overloaded, down for maintenence, or not fully functional for another reason.

When you see this error in relation to Varnish Cache, it means that the website is using Varnish Cache to cache and serve content, and that Varnish Cache is unable to reach the back end server. Varnish Cache issues the Guru Meditation error when a connection has timed out or the Varnish Cache server has made too many requests to the back end server without getting a response. Instead of making an infinite number of requests to an unhealthy back end, Varnish Cache issues the 503 error to let the visitor (and website owner) it is likely the website manager is already working on a fix and your best bet is to try again later. If you are the website manager or owner and aren’t sure why you are getting this response, read below to find out.

Fixing a Varnish Cache Server Error

So, if your website is producing a Guru Meditation 503 error through Varnish Cache, how do you go about fixing it? First you’ll want to look at the logs for all the 503 errors by using varnishlog. You can get varnishlog to log 503 errors by using the below command from Varnish Cache:

    $ varnishlog -q 'RespStatus == 503' -g request

Regularly you will get 503 errors because your back end is down or unhealthy. In this case varnishlog could return something like “FetchError c no backend connection.” You should check the port Varnish Cache is trying to connect to, the origin server, and your HTTP service such as Apache or Nginx and see if all of that is operating correctly - if it is not, you’ll need to troubleshoot your back end.

If your back end does seem to be up but you are still getting a Varnish Cache 503 error then there is something wrong with your web server’s connection to Varnish Cache or the Varnish Cache configuration.

If your back end is responding but Varnish Cache is serving 503 we often find this is due to timeouts. You can change or add a .connect_timeout = Xs and a .first_byte_timeout = Xs in the backend default VCL section to a timeout length that works for your web server. Varnish Cache Software has more information on the various timeouts that can occur in Varnish Cache. Another tip is to disable KeepAlive so that idle connections will be dropped. This would look like the below:

  "origin": {
       "address": "origin.example.com",
       "disable_keepalive": true
   }

For more information on Varnish Cache download the Section Varnish Cache 101 Guide or contact us if you need help troubleshooting your Varnish Cache setup.

varnish cache tutorial

Similar Articles