How to Fix Error 503 Backend Fetch Failed on Your Website?

The Error 503 Backend Fetch Failed is a server-side error that can render a website wholly or partially unusable. This error can occur when attempting to access a website, download content, or utilize a payment processor, to name a few.

Error 503 Backend Fetch Failed
Error 503 Backend Fetch Failed

This error indicates that the website’s server could not communicate effectively with the back-end services. It is commonly triggered by updates to plugins, server OS, or extensions. Because it’s a server-side problem, clients can only attempt to refresh the website in their browsers.

If you are experiencing this issue on a website, it is advisable to contact the web administrators to rectify the error on their end.

Basic Troubleshooting

  1. Reload the Browser Page: Temporarily resolve the error 503 by refreshing the page a few times.
  2. Server Status: Verify if the host server is down or undergoing maintenance.
  3. Backup: Ensure that you have a backup of the server, website, and database to prevent data loss while troubleshooting.
  4. Reload or Restart Services and Server: Try reloading or restarting services, such as Varnish, and if the error remains, consider restarting the server.
  5. Update: Check that all related services, applications, and server OS are up-to-date.

3. Check the Website Health and Resources 

Insufficient storage or resources on a website can cause the backend fetch failed issue due to the inability to carry out necessary operations.

  1. Navigate to the WordPress dashboard and select Tools > Site Health > Info.
    Check Storage Size of Your Website on WordPress
    Check the Storage Size of Your Website on WordPress
  2. Assess whether the storage is nearing its limit. If so, you may need to add more storage or purge unnecessary items. In some cases, it might be necessary to upgrade your plan.
  3. Make sure that other server resources are not being overwhelmed and that resolving this issue eliminates the error.

4. Check the Resource Availability

Attempting to access an absent resource on the backend server will result in an error message. Your reverse proxy might report this as a 503 backend fetch failed error.

  1. Check the URL or code and determine which resource it is trying to access.
    Check the Resource Availability on the Server
    Check the Resource Availability on the Server
  2. Verify the availability of the requested resource on the server. If absent, upload the resource to the appropriate location.
  3. If the problem continues, ensure the action being executed doesn’t attempt to load the entire website. For instance:
    .request ="GET HTTP/1.1"

    Revise the command as follows:

    .request ="GET /sitehealth.html HTTP/1.1"

5. Change the Cloudflare Settings

Suboptimal Cloudflare settings can cause an error 503 by restricting access to backend server resources. Changing these settings can rectify the issue.

  1. Access the Cloudflare dashboard and go to Security > Make Changes on Elementor.
  2. Copy the IP displayed and go to WAF > Tools.
  3. Click Edit next to your website entry and add the IP to the allowed list.
    Add the IP as an Allowed One in the Cloudflare's WAF Tools
    Add the IP as an Allowed One in the Cloudflare’s WAF Tools

6. Increase the Server Time-Out Limit

If the backend server’s response time is longer than what the reverse proxy is set to wait for (timeout), a backend fetch error will occur. Increasing the server’s time-out limit can address this problem. This may vary, but in Varnish, it can be done by:

  1. Navigating to the Varnish configuration. For example:
    /etc/sysconfig/varnish
  2. Editing the VCL Conf file to increase the wait time to, say, 300s (the default is often 60s):
    first_byte_timeout = 300s
    Change the Timeout Limit of Varnish
    Change the Timeout Limit of Varnish
  3. Save changes and verify if the error persists.
  4. If the error began following a Varnish config change, revert to an older, functional configuration if available.

7. Edit the Health Check Settings of the Website

The backend error may arise if the reverse proxy cache, like Varnish, is unable to access, or perceives the backend server health check information as faulty. The resolution is to repair the health check settings of the website:

  1. Remove the following line from your configuration if it exists:
    .url="/health_check.php"
    Remove the Health_Check from the Varnish Configuration
    Remove the Health_Check from the Varnish Configuration
  2. Verify if the problem has been resolved.
  3. If not, deploy varnishlog to identify what is being marked as unhealthy and address it accordingly.
    sudo varnishlog -g request -q "VCL_call eq 'BACKEND_ERROR'"

8. Revert the PHP Version of the Server

If a recent PHP version upgrade is incompatible with your website’s backend, a 503 error may be triggered. Reverting to a prior PHP version can solve the issue. For example, on Bluehost with WordPress:

  1. Proceed to the Bluehost dashboard and select the Advanced tab.
  2. Within cPanel, navigate to MultiPHP Manager in the Software section and select the affected website.
  3. Change the PHP Version back to the earlier version and verify if the error has been resolved.
    Revert the PHP Version of the Website
    Revert the PHP Version of the Website

9. Disable Plugins, Utilities, Extensions, and Themes

When a plugin, utility, extension, or theme is incompatible with a server setup, a 503 error may result. Mitigate the error by disabling them and re-enabling one at a time to pinpoint the troublesome element.

For instance, to disable GZip on the Jira Service Desk, which has been known to cause a 503 error:

  1. Head to the Jira dashboard and select Admin > General Settings > Use GZip Compression.
    Disable GZip on Jira
    Disable GZip on Jira
  2. Disable GZip compression and see if it resolves the error.

10. Disable the CSP Module on Magento

The Content Security Policies (CSP) module provides security for Magento applications. If the CSP module is incompatible with your current setup, it can trigger a 503 error.

Disabling the CSP Module on Magento could solve the issue:

  1. Launch Terminal and run the following commands successively:
    php bin/magento module:disable Magento_Csp
    php bin/magento c:f
    Disable Magento CSP Module
    Disable Magento CSP Module
  2. After execution, check if the error 503 has been corrected.

11. Change Host Header, Child Tag, and Port Configurations

Backend fetch errors can also stem from overly large host headers, improperly configured child tags, or incorrect port configurations. Editing these settings might rectify the error.

Add a .host_header Property

  1. Implement a .host_header property for the backend server to ensure probes are directed to the correct host.
    Add a Host Header Property to the Server
    Add a Host Header Property to the Server
  2. Embark on debugging to inspect the incoming host header details within the logs.

Remove Child Tags from Magento

  1. Access this file:
    Magento\ConfigurableProduct\Plugin\Model\Product
    Remove Child Tags from the Magneto Header
    Remove Child Tags from the Magento Header
  2. Expunge the child tag from the header and evaluate if the error is resolved.

Remove Ports from the Docker Compose

  1. Locate the Docker Compose and navigate to the Default.vcl file.
    Remove Ports from the Docker Compose
    Remove Ports from the Docker Compose
  2. Replace ports with the service name as depicted below:
    client:
    image: ...
    ports: <-- remove
    - target: 80
    published: 8080
    mode: host

    Adapt the Default.vcl accordingly:

    backend default {
    .host = "client";
    .port = "80";
    }
  3. Examine if this amendment resolves the issue.

12. Use a Systematic Approach

If all previous steps have failed, a systematic approach should be employed to isolate the cause of the error 503.

Check Logs

  1. Scrutinize the logs associated with reverse proxies, PHP, backend servers, or hosting configurations for any irregularities that might instigate the error 503.
    Check PHP Logs
    Check PHP Logs
  2. If an anomaly is detected, rectify the underlying issue to eliminate the error.

Do a Full Conflict Test

Perform a full conflict test if your setup permits, to discover any potential conflicts. If any conflicts arise, resolve them to clear the backend fetch error.

Perform a Conflict Test on Magento
Perform a Conflict Test on Magento

Directly Access the Backend Server

If you are utilizing a reverse proxy like Varnish, bypass it and try directly accessing the backend server. If this method works, the issue likely lies with the reverse proxy setup. Consider the following steps if direct access is successful:

  1. Assess the cache tags’ length used by Magento—especially relevant for stores with many products—as they might exceed the default limit set in Varnish (typically 8192 bytes). To rectify, modify the http_resp_hdr_len (e.g., to 70000 bytes) in Varnish’s configuration. Correspondingly, adjust Varnish’s http_resp_size.
    Increase Header Length of Varnish and Response Size
    Increase Header Length of Varnish and Response Size
  2. Ensure that the health_check.php file is in the right directory or modify the Varnish configuration to point to the accurate location. The default may be /pub/health_check.php, but for Nginx servers, it may need to be changed to /health_check.php.
  3. For Magento sites, if a maintenance.flag file exists, try deleting or renaming it and then refresh the website to see if the error is resolved.
  4. Investigate the Product Rules within Magento through a backtrace to identify any invalid outputs that may be causing the error.

If these methods are ineffective, strip down the website to its most fundamental elements, such as an index file with some placeholder content. Gradually reintroduce features to determine which one triggers the error 503. If the problem continues, reach out to the appropriate support channels for assistance, be it WordPress Support, Magento Support, or the hosting provider’s customer service team, such as Hostinger Support.

ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.