18 March, 2023

What is a 504 Gateway Time-out error? Causes and fixes

Mistake 504 gateway timeout is one of the most common errors when visiting a website, and it stops users from reaching the page they want. So what exactly is a 504 error? What causes it, and what are the most effective fixes? In the article below, MONA Media will answer all of these questions.

What is a 504 Gateway Time-out error?

Gateway Timeout error is an error that a server (server) returns when it can't complete a request, caused by one of the HTTP status codes. This error appears less often than the 502 bad gateway error or 500 internal server errorerror. Still, anyone who browses the internet has probably run into a 504 Gateway Time-out at least once.

What is a 504 Gateway Timeout error?

A server-side error is recognized when the HTTP status code starts with "5". A 504 Gateway Timeout appears when servers lose contact while communicating with each other and the request isn't completed. In other words, when a server gets no response from proxy or from another gateway server, it can't complete the request within the time limit.

This error shows up in the browser window in many forms, such as:

  • 504 Gateway Time-out Nginx
  • Gateway Time out Error
  • HTTP Error 504 – Gateway Time-out
  • 504 Gateway Time-out
  • 504 Error
  • Gateway Timeout (504)

In addition, in Windows programs that access the internet on their own, the 504 error usually appears in a small dialog or window with the HTTP_STATUS_GATEWAY_TIMEOUT error and/or the message "The request was timed out waiting for a gateway”.

There is also a less common 504 error: "Gateway Time-out: The proxy server did not receive a timely response from the upstream server“.

What causes a 504 Gateway Time-out error

What causes a 504 error

The 10+ years working with many clients, MONA has handled many 504 errors on websites and answered questions about what causes them. From this work we've put together the common causes of a 504 Gateway Time-out below:

  • The server can't handle many high-load requests at the same time, which overloads it and causes a 504 Gateway Time-out.
  • Incorrect proxy or gateway configurationcan also lead to a 504 error.
  • An unstable internet connection between the server and the proxy or gatewaycan also cause a 504 error.
  • A software or hardware fault on the proxy server and gateway can also produce a 504 error.
  • In addition, a maximum timeout on the proxy server or gateway that is set too short is another common cause of the 504 error.

The most effective ways to fix a 504 Gateway Time-out error

Reload the page or refresh the website

Fixing a 504 error by refreshing the website

The reason may be that the server received more requests than usual and couldn't keep up. The first fix for a 504 Gateway Time-out is to wait a few minutes and reload the page (refresh website). In the meantime, use a website checker to see whether the site is down. If the site is still working normally, the problem is on your local machine, not the server.

Try a different browser

If the 504 Gateway Time-out still appears while the website is up and active, try a different web browser. You can also open Incognito Mode or try to clear the cache to deal with any error tied to the browser you're using.

Clear the DNS cache to fix a 504 Gateway Time-out

Clear the DNS cache to fix a 504 Gateway Timeout

Based on our experience researching and fixing website problems for clients, MONA has found that a 504 Gateway Time-out sometimes comes from a DNS cache that is DNS Cache wrong or out of date. If that's the cause, the fix is simple: just flush the DNS. Note, though, that the way to clear the DNS cache differs by operating system. So, temporarily switch your DNS server to Google Public DNS to resolve the HTTP status code error if DNS is the cause.

Check the page on another device

If you're on a mobile phone using 4G, try opening the website on a different device and a different network. If it loads normally, the problem is with the device you were using, not the server.

Check how the page loads on other devices

Check the error log

An update or a recent website change can also cause a 504 error. This is easy to fix: add the 3 lines below to the file wp-config.php:

  1. Define( ‘WP_DEBUG’, true );

  2. Define( ‘WP_DEBUG_LOG’, true );

  3. Define( ‘WP_DEBUG_DISPLAY’, false );

–> Then save the changes to the file wp-contents/debug.log

Check your CDN

If you use CDN to speed up content delivery, check it, because the 504 Gateway Time-out may come from there. It may be because CloudFlare is acting as a CDN and reducing DDoS attacks. If the error is caused by CloudFlare, contact the provider for support. If you disable CloudFlare, wait a few hours for DNS to propagate.

Check your plugins

Check plugins to fix a 504 error

The 504 Gateway Timeout may also be caused by outdated or incompatible plugins. In that case, MONA suggests disabling the plugins to see whether the error is plugin-related. It's easy:

  • First, to disable WordPress plugins, go to the wp-content folder, then rename the Plugin folder.
  • Next, find the exact plugin causing the error by renaming it back to the name you used before.
  • Finally, carry out deactivation in order for each plugin.

To learn more about WordPress plugins, take a look at a few popular ones below:

Adjust the server configuration

If you're using VPS Hosting, adjust the server and upgrade some resources.

For Apache servers

  • Open the file http.conf => then increase the default Timeout value to
  • Open the file php.ini => to raise the limit max_execution _time
  • Save the changes
  • Starter Apache
  • Check whether the 504 error is gone

For Nginx servers

  • File /etc/nginx/conf.d/timeout.conf => to raise the limits of these values:
  1. Proxy_connect_timeout 600
  2. Proxy_send_timeout 600
  3. Proxy_read_timeout 600
  4. Send_timeout 600
  • In the file php.ini => raise the limit max_execution_time
  • Save and restart Nginx
  • Try opening the website again

Restart and reconnect your internet devices

Restart your internet devices to give the website a stable connection

Sometimes a 504 error comes from an unstable internet connection that makes the website fail to load. Try restarting your device first. If that doesn't help, turn off and restart your wifi modem, router and other network devices to restore a stable connection.

Fix a 504 Gateway Time-out on your own website

Check whether your server can correctly resolve all the application domains that need access. If organic is too large, your server may also show a 504 error, although a 503 may be more accurate.

Over WordPress, the message "504: Gateway Time-out" may appear because the database is corrupted. In this case, you need to install WP-DBManager and then try the "Repair DB" feature, followed by "Optimize OB" to see if it helps. Make sure the file .htaccess has no problems, especially if you've just reinstalled WordPress.

Fix the 504 Gateway Time-out error

Contact your hosting provider

If you've tried everything above but the 504 Gateway Time-out error is still there, contact the provider of your Web Hosting. Describe in detail what you've already tried and give them the related information so their technicians can help you faster and more effectively.

Errors similar to 504 Gateway Time-out

Because all of these happen on the server side, some error messages look alike, such as "504 Gateway Time-out". A few others are 500 Internal Server errors, 504 Service Unavailable, 502 Bad Gateway errors and so on.

There are also HTTP status codes that come from the client side rather than the server, for example the commonly seen error 404 Not Found and error 401 Unauthorized Error.

That is the detailed answer to the question "What is a 504 Gateway Timeout error?" and a roundup of the quickest, most effective ways to fix the 504 Gateway Time-out error . We hope the tips from MONA Media are useful to you. Good luck fixing your 504 error!

MONA has a podcast: listen instead of readingEpisodes on AI, automation & SEO for Vietnamese businesses
Nghe ngay
About the author

CEO & Founder · The MONA

Founder of The MONA, who built a services company of 200+ staff with 14,000+ projects delivered. Khánh Hùng shares how he thinks about building systems that run themselves, automating a business, and the real lessons from delivering projects at MONA.

Views 1,5K
Rate this article 4,8/5 · 10 ratings

Related articles

Professional website
design services

Own a website with a beautiful, 100% exclusive design and a lifetime warranty, with the ability
to expand features flexibly as your business grows, starting today!

Contact Mona

    MONA có riêng một Người "Bạn Thân" cho bạn - Người Account sẽ đồng hành, hỗ trợ, hướng dẫn, đặt đồ ăn cho bạn mãi mãi, từ đây về sau!
    MONA will never sell your information or send you spam
    Đội MONA tư vấn hệ thống quản lý giáo dục trực tuyến
    Hỏi đáp giáo dục 4.0
    Tạo cuộc hẹn miễn phí với MONA để giải đáp và tư vấn mọi thắc mắc về giải pháp số hoá ngành giáo dục
    Thời lượng cuộc hẹn
    45 Phút
    Ngày và giờ
    Thứ 2, ngày 25 tháng 12, 2023
    [9:30 - 10:15]

      Chọn ngày và giờ
      Khung giờ
      Back
      Hãy cho MONA biết bạn là ai
      0:00