My website keeps crashing and giving an "error 503 backend fetch failed" error when you try to go to it. To temporarily fix it I reset my server the website is hosted on, and it seems to fix the problem momentarily. But normally within 8-12 hours the website will crash again and give the same backend fetch failed error. The exact error reads:
Error 503 Backend fetch failed
Backend fetch failed
Guru Meditation:
xid: XXXXXXX<-----(random number every time the error comes up)
Varnish cache server
I changed the config based on suggestions I found in Magento DevDoc but nothing seems to work: https://devdocs.magento.com/guides/v2.3/config-guide/varnish/tshoot-varnish-503.html
Screenshot of error:
Does anyone have any ideas what the problem may be?
Hello @matt_nelsen
Try to fetch the website without varnish to see if the error is in varnish or the webserver, in your case, it seems from the hosting side.
For example, if you have a different hostname for the webserver, load that and find the error, if you can fix that,
Restart varnish and it should resolve your issue.
Anybody else have a similar problem?
I have the same problem as you mention. you may want to take a look at this post
Hi!
First of all, you have to identify why this error is occurring again and again. It can be due to various reasons:
1. lack of memory.
2. The varnish is not working from the backend.
3. The extensive number of requests on the server.
4. SSL couldn't configure successfully
How to fix this issue?
look for the scalability if you can or ask the hosting provider to do it for you. Second, remove the maintenance.flag file and hit the URL again.
If it works with you, do let me know!
Hello matt_nelsen,
The most common error that Magento 2 user encounter is 503 Backend fetch failed with varnish cache. Here are some possible causes for the error to occur,
Length of cache tags utilized by Magento exceeds Varnish's default value:
If your store has many products (more than 400), the error might occur because the length of cache tags utilized by Magento 2 exceeds the default value of Varnish. The default value of Varnish is 8192 bytes.
We'll have to change the http_resp_hdr_len value in the Varnish configuration file to fix the issue.
The path to the varnish configuration file,
Ubuntu: /etc/default/varnish
Centos 6: /etc/sysconfig/varnish
Centos 7: /etc/varnish/varnish.params
Then, edit the file with a text editor and change the http_resp_hdr_len value.
From:
-p http_resp_hdr_len=8192 \
To larger value:
-p http_resp_hdr_len=70000 \
Now, change http_resp_size to the value that fit the increased value of http_resp_hdr_len,
From:
-p http_resp_size=32768 \
To:
-p http_resp_size=100000 \
Lastly, save the file and restart Magento 2 server to apply changes.
Wrong health_check.php location in the Varnish config file:
The other cause for the error to appear is the wrong health_check.php file location in a varnish configuration file.
By default, the path to the health_check.php file in varnish is /pub/health_check.php
In Magento 2, nginx.conf.sample already set root path to /pub > that is the wrong path in a varnish configuration file.
Firstly, navigate to the Varnish configuration file (/etc/varnish/default.vcl) and locate the below lines:
.probe = { .url = "/pub/health_check.php";
Next, change it to:
.probe = { .url = "/health_check.php";
Then, navigate to the nginx.conf.sample file in Magento 2 root folder, locate the following lines:
location ~ (index|get|static|report|404|503)\.php$ {
Now, add health_check to the above line to allow the health_check.php file as below,
location ~ (index|get|static|report|404|503|health_check)\.php$ {
Lastly, save changes and restart varnish and nginx to apply changes.
Maintenance.flag file developed by Magento 2:
The error can also be caused by the var/.maintenance.flag file generated by Magento 2 when you install new extensions/themes or maintain, upgrade, or reconfigure your site.
In order to fix the issue, you can open a file manager and rename/remove maintenance.flag file and refresh your website to see if the error is resolved.
Thus, I hope the methods mentioned above help you to fix the Error 503 Backend fetch failed with a varnish cache.
-------------------------
Regards,
Rex M
There could be a few reasons why your Magento site keeps crashing with a 503 Backend Fetch Failed error:
Resource Limitations: The most common cause is the backend server running out of memory or maxing out the CPU, so it fails to respond to requests from Varnish. Check usage when the site crashes and optimize/scale up resources if needed.
Caching Issues: Problems with caching configuration can cause the backend to be hit repeatedly and get overloaded. Ensure Magento and Varnish caches are configured properly and cache flush/invalidation is working.
Some specific things to try:
Hope this gives you a framework to debug the intermittent crashes.
I’m sorry to hear about the issues you’re facing with your website. The "Error 503 Backend fetch failed" typically indicates that Varnish, the caching server, is unable to fetch data from your backend server. This can be due to a variety of reasons such as server overload, configuration issues, or connectivity problems.
Given that resetting your server provides only a temporary fix, it’s crucial to delve deeper into the root cause. You mentioned you’ve tried some solutions from the Magento DevDocs, which is a great start. However, this issue can be complex, and sometimes additional troubleshooting steps are necessary.
I recommend checking out this guide on fixing Error 503 with Varnish cache for more insights and potential solutions. It covers various aspects that might not be addressed in the Magento DevDocs.
If the problem persists, you might also want to consider reviewing your server logs for more specific error messages or consulting with a specialist who can provide a detailed analysis.
I hope this helps!