Bobcares

Varnish cache server error 403 – Quick Fix!!

by | Nov 7, 2019

Oops!! Getting frustrated with Varnish cache server error 403?

Usually, this error occurs due to the caching of error pages, IP rate limiting by backend apps, etc.

Varnish misconfiguration adds additional headaches to server owners.

At Bobcares, we often receive requests to fix such errors as part of our Server Management Services.

Today, let’s check the Varnish 403 error in-depth and see some of its top fixes by our Support Engineers.

 

What is a varnish cache server error 403?

Before getting much into the error, let’s discuss the Varnish cache in brief.

So, Varnish cache a.k.a caching HTTP reverse proxy is basically a web application accelerator.

It increases the speed of a website while reducing the load on the webserver. Moreover, it is well known for its flexible configuration language, VCL.

Though it has excellent performance, it is never free of errors. And, error 403 is common in varnish and often tricky too.

So, now let’s check how our Support Engineers fix it easily.

 

How we fix varnish cache server error 403?

We’re all familiar with the error 403, isn’t it?

As we all know, a 403 Forbidden error occurs when a webserver forbids us from accessing the page we’re trying to open in our browser.

 

 

But, now let’s check why this error occurs in varnish and how can we fix it easily. This error mainly occurs due to two reasons.

 

1. Caching of error pages

This is one of the main reasons causing the varnish 403 error.

Mostly, the backend might return 403 only once. But, varnish caches it for future requests.

So, we require varnish to not to cache any error pages. For that, we need to edit the vcl_fetch section.

We call vcl_fetch after a document has been successfully retrieved from the backend. Also, it has a backend response, beresp that contains HTTP headers from the backend.

if (beresp.status >= 400) {
return (hit_for_pass);
}

Adding the above code in the vcl_fetch section resolves the error.

 

2. Rate limiting per IP

Sometimes, the backend may appear forbidden. Varnish returns this error indicating that the backend is giving 403 errors.

Mostly, this occurs when the backend apps use some sort of rate limiting per IP. When we add varnish to an existing setup, the IP that has been passed to the backend is the varnish is not the source IP.

In such cases, we update the X forwarded by adding the below code to vlc_recv section,

remove req.http.X-Forwarded-For;
set req.http.X-Forwarded-For = client.ip;

This code ensures that the correct client IP has been passed into varnish and prevent itself from throwing 403 error.

 

[Need more assistance to solve Varnish error? – We’ll help you.]

 

Conclusion

In short, Varnish cache server error 403 occurs due to caching of error pages, rate limiting per IP by backend apps and so on. Today, we 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";

14 Comments

  1. Kay

    what is vlc_recv section, and where is it? Thanks.
    K

    Reply
    • Hiba Razak

      vlc_recv is executed when Varnish receives a new request. Thus, in vlc_recv we instruct Varnish how to respond to each new request.

      Reply
      • Abdilahi

        My PayPal account don’t work

        Reply
        • Hiba Razak

          Hi,
          Please contact our support team through live chat (click on the icon at right-bottom).

          Reply
      • John

        They asked WHERE it was (located), not WHAT it does.

        Reply
        • Hiba Razak

          The vcl_recv section resides within a VCL file, typically named default.vcl. This file is located in the Varnish configuration directory, which varies depending on your operating system.

          In Linux/Unix: The default location is usually /etc/varnish/default.vcl.

          Reply
  2. Roy

    Hi,
    I have a user problem with logging in. I get the following message:
    Error 503 Backend fetch failed
    Backend fetch failed
    Guru Meditation:
    XID: 993910024

    Reply
    • Hiba Razak

      Hello Roy,
      Our Experts can help you with the issue, we’ll be happy to talk to you on chat (click on the icon at right-bottom).

      Reply
    • Abdilahi

      I don’t login my PayPal acount

      Reply
  3. Aziz

    ça ne marche pas

    Reply
    • Hiba Razak

      Hi Aziz,
      Please contact our support team via live chat(click on the icon at right-bottom).

      Reply
  4. Aziz

    ça refuse de rentre sur un site

    Reply
  5. PHIL GOBIN

    Error 403 Forbidden
    Forbidden

    Error 54113
    Details: cache-mia-kmia1760051-MIA 1682949318 3897479579

    Varnish cache server

    Reply
    • Hiba Razak

      Hi,
      Please contact our support team through live chat (click on the icon at right-bottom).

      Reply

Submit a Comment

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

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

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

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

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