For anyone here who is interested (Hopefully Staff) :)

TheGremlin

New Member
Messages
21
Reaction score
0
Points
1
SOLVING THE DREADED VARNISH 503 ERROR

“Error 503 Service Unavailable” / “Guru Meditation” is probably the most common error people get with Varnish. This post will go through a few causes of (and solutions to) this Varnish 503 error.

BEFORE WE START
One of the most confusing (but nonetheless very cool) things about Varnish is that it does not store any logs on disk. All log entries go directly into memory. This allows for better performance and efficient disk usage.

So to view the logs, you’ll have to fire the following command: varnishlog

Once the command is running, load up a page from your website on your browser and look for any errors. This literally means looking for the word “error”.

Pretty sweet, huh! Now let’s get on to our first solution.

SOLUTION 1 – GENERAL CHECK
Most of the times, Varnish 503 means Varnish cannot connect with your backend (Apache, Nginx, etc…). So you should start from there.

The first thing is to make sure your backend is correctly configured. That means making sure your Apache/Nginx/whatever is running properly before installing Varnish.

If you’ve installed Varnish on a properly running instance, then you might just check that installing Varnish hasn’t done anything funny to your Apache configurations. Here’s what you can do:

Open your Varnish configuration file. Mine was in /etc/varnish/user.vcl

backend default {
.host = "127.0.0.1";
.port = "8888";
.connect_timeout = 1s;
}
We can see that Varnish is trying to connect to port 8888 on the same machine. But is our backend responding correctly there?

Let’s try this (make sure you run this on your server, this port will probably be blocked to the outside world):

wget http://www.your-site.com:8888
This will create an HTML file with the output in your current directory. Open the file and see if it matches your website’s homepage. If it does not, then you need to configure your server. This is beyond the scope of this post, I’ll advise you to check the Linode Library for resources.

SOLUTION 2 – INCREASE TIMEOUTS

A frequent cause of Varnish 503 errors is timeouts between Varnish and your backend. This is quite easy to solve.

Open your Varnish configuration file (mine was in /etc/varnish/user.vcl) and add these lines:


backend default { .host = "127.0.0.1"; .port = "8888"; .connect_timeout = 1s; # Wait a maximum of 1s for backend connection (Apache, Nginx, etc...) .first_byte_timeout = 5s; # Wait a maximum of 5s for the first byte to come from your backend .between_bytes_timeout = 2s; # Wait a maximum of 2s between each bytes sent }


The settings are pretty straightforward. The most important settings here is thefirst_byte_timeout. So go ahead and play with those settings until you find the sweet spot for your server.

SOLUTION 3 – TURN KEEPALIVE OFF
If you’ve increased the timeouts and you’re still getting Varnish 503 errors, then the problem might be elsewhere.

Do this test; increase your timeouts to a considerable amount, like 10 seconds. Then, start browsing your website until you get a 503 error. If the error comes up before those 10 seconds, then the error is definitely elsewhere. I’ve seen cases where the error was coming up right after the click, as if the page was cached locally.

The solution to this issue is quite simple. It occurs often on Apache servers and it’s all due to the KeepAlive directive.

Open your Apache configuration file. Mine was in /etc/apache2/apache2.conf

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive Off
By turning the KeepAlive directive off, we are forcing Apache to drop idle connections. Turning KeepAlive on makes sense when your Apache instance serves files directly to the end users. Basically the end user will open one connection and receive multiple files from it.

But with Varnish and Apache on the same server, I’d advise you to turn KeepAlive Off.

WRAPPING UP
So there you go with my suggestions. Go ahead, try them and let me know if you have any other solutions!


 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
IMO - most - if not all - of this thread is not applicable for x10hosting's cluster(s) - virtual servers(50+) setups - and networks
 
Last edited:

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hi,

While I appreciate that you've found an article on Varnish, the article you have found describes how to configure Varnish. Our Varnish and Apache setup is already configured correctly, and this information does not really apply for intermittent 503 error messages. We are already aware of how Varnish works, and our Apache & Varnish configuration is already working correctly.

Just to clarify, a 503 error message is shown when Varnish is unable to communicate with Apache. This can happen when the script you are accessing takes longer than 30 seconds to produce a response, or the web server is temporarily experiencing issues. If Apache is under more load than usual, a 503 error message may be served if Apache is unable to serve the request.

Our free hosting monitoring system does not show any issues in the last few hours, and I can't see any issues with 503 errors at this time. If you are seeing 503 error messages on your site, please report this in the Free Hosting section.

Please let me know if you have any further questions.

Thank you,
 

caftpx10

Well-Known Member
Messages
1,534
Reaction score
114
Points
63
Hi,

While I appreciate that you've found an article on Varnish, the article you have found describes how to configure Varnish. Our Varnish and Apache setup is already configured correctly, and this information does not really apply for intermittent 503 error messages. We are already aware of how Varnish works, and our Apache & Varnish configuration is already working correctly.

Just to clarify, a 503 error message is shown when Varnish is unable to communicate with Apache. This can happen when the script you are accessing takes longer than 30 seconds to produce a response, or the web server is temporarily experiencing issues. If Apache is under more load than usual, a 503 error message may be served if Apache is unable to serve the request.

Our free hosting monitoring system does not show any issues in the last few hours, and I can't see any issues with 503 errors at this time. If you are seeing 503 error messages on your site, please report this in the Free Hosting section.

Please let me know if you have any further questions.

Thank you,
When I got the error and created a thread, you had replied saying that you couldn't see it logged. Was what was suggested in this thread (varnishlog) or something similar used?
 

TheGremlin

New Member
Messages
21
Reaction score
0
Points
1
IMO - most - if not all - of this thread is not applicable for x10hosting's cluster(s) - virtual servers(50+) setups - and networks

If not applicable, then why are the boards full of complaints about 503 errors ? It is obviously an issue, if this is not the cause, then what is ? and why not figure it out and fix it. ?
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
If not applicable, then why are the boards full of complaints about 503 errors ?
what I said was - the cure-all solutions in your post (#1) are not applicable to the configuration of x10hosting's clustered virtual servers - and the hardware - and the networking ( interconnecting ) they use
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hi,

If not applicable, then why are the boards full of complaints about 503 errors ? It is obviously an issue, if this is not the cause, then what is ? and why not figure it out and fix it. ?
Currently, there are no issues with 503 errors, and I have already responded to all support threads about the 503 errors. I have also offered an explanation for the common causes of 503 error messages, in my previous post. Is there anything else I can help with? :)

Thank you,
 

glennemlee95

Member
Messages
59
Reaction score
2
Points
8
Hold up a sec, x10 is already using Varnish caching for all sites? That means I don't need to use a caching plugin for my WordPress install right? I'm actually beating a dead horse here?
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hold up a sec, x10 is already using Varnish caching for all sites? That means I don't need to use a caching plugin for my WordPress install right? I'm actually beating a dead horse here?
Resources on free hosting users' sites are already cached with Varnish, yes. ;)

When I got the error and created a thread, you had replied saying that you couldn't see it logged. Was what was suggested in this thread (varnishlog) or something similar used?
Sorry; I was reading back and it looks like I missed your post. By the time I saw your thread, the error message was no longer showing. I checked both Apache and our monitoring system to see if there were any problems.
 
Top