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, chances are at some point you will come across the Varnish 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 to cache and serve content, and that Varnish is unable to reach the back end server. Varnish issues the Guru Meditation error when a connection has timed out or the Varnish 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 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, 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 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 503 error then there is something wrong with your web server’s connection to Varnish or the Varnish configuration.

If your back end is responding but Varnish 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 Software has more information on the various timeouts that can occur in Varnish. 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.io Varnish Cache 101 Guide or contact us if you need help troubleshooting your Varnish setup.

varnish cache tutorial

Blog Categories

Interested in articles about a specific topic? Click on a category to see all related content.

section.io Sign up

Want to get started improving your website performance, scalability, and security? Sign up for a 14 day free trial of section.io and see what we can do for you!

Get started