cancel
Showing results for 
Search instead for 
Did you mean: 

Error 503 Backend fetch failed

Error 503 Backend fetch failed

Hi,

I am getting error 503 backend fetch failed when using varnish. I am using Ubuntu and nginx with lets encrypt SSL.

I have made nginx listen on port 8080 and varnish on port 80, but if i try to access any magento url on port 8080 i get error 404 which is what is causing the error 503. Everything was working fine before i enabled varnish and switched the listening port for nginx.

I have posted https://stackoverflow.com/questions/70608310/varnish-503-backend-fetch-failed/70619752#70619752 but no suggestions helped.

I have not edited the nginx.conf.sample file that comes with magento, just renamed it to remove the .sample at the end.

I run phpmyadmin from the default nginx location and that is working fine, so its definitely a magento config or my mysite.com.conf nginx file. Can anyone shed any light on where i might have gone wrong? I have included my mysite.com.conf file which in /etc/nginx/sites-enabled/

 

upstream fastcgi_backend {
        server  unix:/run/php/php7.4-fpm.sock;
}

server {
   listen 8080;
   listen [::]:8080;
   server_name mysite.com;
#  return 404; # managed by Certbot
   set $MAGE_ROOT /var/www/mysite.com;
   access_log  /var/log/nginx/mysite.com.log;
   error_log   /var/log/nginx/mysite.com.err;
   include /var/www/mysite.com/nginx.conf;

#   if ($host = mysite.com) {
#        return 301 https://$host$request_uri;
#    } # managed by Certbot

    # PHP entry point for main application
#    location ~ (index|get|static|report|404|503)\.php$ {
#        try_files $uri $uri/ =404;
#        fastcgi_pass   fastcgi_backend;
#        fastcgi_buffers 1024 4k;

#        fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";
#        fastcgi_param  PHP_VALUE "memory_limit=4096M \n max_execution_time=18000";
#        fastcgi_read_timeout 6000s;
#        fastcgi_connect_timeout 6000s;

#        fastcgi_index  index.php;
#        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
#        fastcgi_param  HTTPS on;
#        include        fastcgi_params;

#        }
}
server {
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    # OCSP stapling
    ssl_stapling                            on;
    ssl_stapling_verify                     on;

#location / {
#       proxy_pass http://127.0.0.1;
#       proxy_set_header Host               $http_host;
#       proxy_set_header X-Forwarded-Host   $http_host;
#       proxy_set_header X-Real-IP          $remote_addr;
#       proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
#       proxy_set_header Ssl-Offloaded "1";
#       proxy_set_header X-Forwarded-Proto  https;
#       proxy_set_header X-Forwarded-Port   443;
       #proxy_hide_header X-Varnish;
       #proxy_hide_header Via;
#       proxy_set_header X-Forwarded-Proto $scheme;
#       proxy_buffer_size                   128k;
#       proxy_buffers                       4 256k;
#       proxy_busy_buffers_size             256k;
#       }

}

I have commented out lots of bits in attempts to fix the issue but none of it works. my domain has been edited to mysite.com for posting here.

1 REPLY 1

Re: Error 503 Backend fetch failed

sudo varnishlog -g raw -i backend_health

This command will provide logging information on the status of the health probe checks.

The fact that you get a 503 Backend fetch failed probably means the backend is not available.

If the backend health logging is inconclusive, we can always look at the transactions that resulted in that 503 Backend fetch failed error.

You can run the following command for that:

sudo varnishlog -g request -q "RespStatus == 503"

Please provide some logging output:

A couple of lines from the backend health logging command
A full log transaction for a request that triggered the 503 Backend fetch failed

If issue solved, Click Kudos & Accept as Solution.
LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool