Magento – Varnish – Error 503 Backend fetch failed

magento2.2.2varnish

I getting this error how can i do? i try to editing many time but still not work.

Error 503 Backend fetch failed
Backend fetch failed

Guru Meditation:
XID: 35

Varnish cache server

My CentOS 7: /etc/varnish/varnish.params

# Varnish environment configuration description. This was derived from
# the old style sysconfig/defaults settings

# Set this to 1 to make systemd reload try to switch VCL without restart. RELOAD_VCL=1

# Main configuration file. You probably want to change it. VARNISH_VCL_CONF=/etc/varnish/default.vcl

# Default address and port to bind to. Blank address means all IPv4
# and IPv6 interfaces, otherwise specify a host name, an IPv4 dotted
# quad, or an IPv6 address in brackets.
# VARNISH_LISTEN_ADDRESS=192.168.1.5 VARNISH_LISTEN_PORT=80

# Admin interface listen address and port VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 VARNISH_ADMIN_LISTEN_PORT=6082

# Shared secret file for admin interface VARNISH_SECRET_FILE=/etc/varnish/secret

# Backend storage specification, see Storage Types in the varnishd(5)
# man page for details. VARNISH_STORAGE="malloc,1024M"

# User and group for the varnishd worker processes VARNISH_USER=varnish VARNISH_GROUP=varnish

# Other options, see the man page varnishd(1) DAEMON_OPTS="-a :80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s
malloc,1024m -p thread_pool_min=5 -p thread_pool_max=500 -p
thread_pool_timeout=300 -p http_resp_hdr_len=65536 -p
http_resp_size=98304 -p workspace_backend=98304"

update:

1) Yes, the vcl file generated by Magento.

2)

tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4338/varnishd

tcp 0 0 127.0.0.1:6082 0.0.0.0:* LISTEN 4337/varnishd

tcp6 0 0 :::80 :::* LISTEN 4338/varnishd

tcp6 0 0 :::8080 :::* LISTEN 3905/httpd

3) i in vcl edited added http:// beacuse when i only /pub/health_check.php will be 503, but added http:// the theme look like something wrong no css.

.probe = {.
url = "http://example.com/pub/health_check.php";

4) i used this command

curl -I -v –location-trusted 'http://example.com'

show this, but i dont know working or not working, beacuse the var/page_cache/ directory is not empty. the mage-tags file still here.

< X-Magento-Cache-Control: max-age=0, must-revalidate, no-cache,no-store

X-Magento-Cache-Control: max-age=0, must-revalidate,no-cache, no-store < Age: 0 Age: 0 <

X-Magento-Cache-Debug: MISS

X-Magento-Cache-Debug: MISS

Best Answer

After compared with the /etc/varnish/default.vcl, I found after removing the .probe section in the backend default can solve this. Still wondering why the probe caused this

backend default {
    .host = "127.0.0.1";
    .port = "8080";
    .first_byte_timeout = 600s;
    .probe = {
        .url = "/pub/health_check.php";
        .timeout = 2s;
        .interval = 5s;
        .window = 10;
        .threshold = 5;
   }
}

to

backend default {
    .host = "127.0.0.1";
    .port = "8080";
    .first_byte_timeout = 600s;
}

Updated:

Just change the following line:

.url = "/pub/health_check.php";

to

.url = "/health_check.php";

solved the problem, refer to this article https://www.sohaib.com/magento-2-12-varnish-error-503-backend-fetch-failed-solved-php-7-1-nginx-varnish-5-x/

Related Topic