Need help?

Our experts have had an average response time of 13.14 minutes in February 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Varnish error 503 – How to resolve it?

by | Nov 8, 2019

Is varnish error 503 frustrating you?

Usually, this error occurs mainly when the webserver becomes unavailable. This can be due to overload, server maintenance and so on.

At Bobcares, we often receive requests to fix this error as part of our Server Management Service.

Today, let’s get into this error in detail and see how our Support Engineers fix it easily.

 

How does Varnish error 503 show up?

As we all know, Varnish is an HTTP accelerator that improves web performance and reduces server load.

If you have a website that caches content with Varnish cache, then you might have come across Varnish cache server error 503: Service unavailable.

varnish_cache_server_error_503

But, why does this happen?

This error indicates that the Varnish is not able to reach the back end server.

There are a few reasons like timeouts, overload, etc that causes this error.

 

Causes and fix for Varnish error 503

Though Varnish is tremendously fast, it often shows up tricky errors like 503.

Let’s now check the various causes of this error and see how our Support Engineers fix it.

 

1. Too many requests

Sometimes, the Varnish cache server makes too many requests to the back end server without getting a response. In such cases, instead of making an infinite number of requests to an unhealthy back end, Varnish cache issues the 503 error.

To fix the error, we initially check the logs for all the 503 errors by using varnishlog. So, we use the command,

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

On checking the logs, we mostly get a “FetchError no backend connection” error. In such cases, we then check whether the ports, HTTP service, original server, etc are operating correctly.

For instance, we will make sure that Apache listens to port 8080

 

2. Timeouts

Sometimes, Varnish cache serves 503 even if backend id responding. This is due to timeouts.

To avoid the errors due to timeout, we add appropriate values for .connect_timeout and .first_byte_timeout in the backend default VCL section. We choose this timeout value based on the application running in the webserver.

Similarly, disabling KeepAlive in order to drop the connections will also resolve the error.

 

3. Length of cache tags

Yet another reason for Varnish error 503 in Magento sites can be the insufficient length of the cache tags.

By default, Varnish supports a default cache length of 8192 bytes. When Magento cache tags exceed this value, it shows error in the browser.

The fix involves increasing the default value of the http_resp_hdr_len parameter in the Varnish configuration file. Further, we increase the default response size using the http_resp_size parameter too.

On CentOS7 server, we set the values in the file /etc/varnish/varnish.params. A sample set of options appear as:

DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
-f ${VARNISH_VCL_CONF} \
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
-p thread_pool_min=${VARNISH_MIN_THREADS} \
-p thread_pool_max=${VARNISH_MAX_THREADS} \
-p http_resp_hdr_len=65536 \
-p http_resp_size=98304 \

Similarly in Ubuntu or Debian servers, we set the values in /etc/default/varnish file.

 

[Need more assistance to fix this error?- We’ll help you.]

 

Conclusion

In short, Varnish error 503 occurs mainly when the webserver becomes unavailable due to too many requests, insufficient timeout values, etc. Today, we have discussed this error in detail and saw how our Support Engineers fix it for our customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF