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.