How to Fix the 504 Gateway Timeout Error in WordPress?

How to Fix the 504 Gateway Timeout Error in WordPress?

HTTP status codes starting with the series digit-5 are the server-side errors, they occur whenever there is any mishap between the several servers.

504 Gateway Timeout Error is one of those server-side errors that happens when the server is unable to complete the request within a particular time span.

How To Fix GateWay Timeout Error

504 Gateway Timeout Error is less common as compared to 500 Internal Server Error and 502 Bad Gateway Error.

Almost every user will face it at least once in lifespan while browsing the internet.

How does server work?

Whenever you visit any website, it will generate a request and send that to the appropriate web servers.

In return, it sends an HTTP Status Code with the requested resources each time you make a request. It will not return any status code if everything is fine.

What does 504 Gateway Timeout mean?

It is an HTTP Status Code which appears only when one server is not able to receive a timely response from another server that may be acting as gateway or proxy. In short, the server was unable to complete your request within the given time frame.

How 504 Gateway Timeout occurs?

Before implementing the solution, it is necessary to understand that how the error arises. Whenever you browse a website, it will send a request on the web server having website hosting. After then, the web server processes the request and send back a status code with the requested resources, also known as HTTP Header. These headers are responsible for the communication between the web server and the web browser. They tell you whether everything is ok or not.

There are the different type of HTTP Status Code. Each code has their unique sense and existence. Most of the error code means that the request is accepted, but the server is not able to fulfill the request.

It is not that all HTTP Status Code is wicked, some of are good too. For instance, HTTP Status Code 200 and it means Everything is OK.

While in the case of 504 gateway timeout error, the server acts as a gateway or proxy server and returns the code when there is a case of timeout or the server is waiting for the response from another server.

Different Presentation of 504 Gateway Timeout Error

A 504 Gateway Timeout error can occur in the number of different ways. They all have the same meaning irrespective of their textual presentation.

  • “504 Gateway Timeout nginx”
  • “Gateway Timeout Error”
  • “HTTP Error 504”
  • “504 Gateway Time-out – The server didn’t respond in time”
  • “HTTP Error 504 – Gateway Timeout”

Some service providers even have their own custom 504 gateway timeout display.

What are the Impacts of 504 Gateway Timeout?

504 Gateway Timeout may have an adverse effect on your site. Let’s discuss with the help of an example.

Suppose your site is down for 10 minutes and it is continuously crawling. Most of the time, it simply gets the page saved in the cache or Google might not even have a chance to re-crawl it before its back up. In this situation, everything is fine.

But in case, if your site downtime increases to 6 to 7 hours, then the Google might see the 504 Gateway Timeout error as a site level issue that needs to be addressed. Otherwise, it will impact your ranking.

Methods to fix 504 Gateway Timeout Error

Typically this is a network related issue, or you can say a server-side problem where your site has hosted. It may be a client-side issue or a third party plugin, theme confliction.

Well, you need to check out all the ways we mentioned below to fix the 504 Gateway Timeout error.

1. Refresh the Page

2. Try a Different Browser

3. Flush DNS

4. Test with Different Devices

5. Check Error Log

6. Check Plugins and Theme

7. Check CDNs

8. Check Server Settings

9. Contact Support

Method 1) Refresh the Page

The simplest method to troubleshoot the 504 Gateway Timeout error is waiting a couple of minutes and try refreshing the tab with an error.

How To Fix Timeout Error Refresh Page

It is because your web server is receiving more traffic than usual at that time and unable to handle more.

For better understanding, you can easily check your website is available or not with the help of online tools. By this, you will be able to know whether the site is down or up. There is the number of online tools available for testing a site is possible or not. You can try them to check your site status.

Method 2) Try a Different Browser

When you test your website online and find that your site is up and it is showing you the 504 Gateway Timeout error, then you need to change the browser. Clear your browser cache or try using incognito window can help you in verifying whether the error is browser related or something else.

Method 3) Flush DNS

504 Gateway Timeout sometimes be a result of incorrect or outdated DNS cache. The method of flushing DNS differs for every operating system.

  • Change DNS for Windows
  • The easiest way to check the error is by changing the DNS servers your device is using.

    1. Click on the Start Menu, then click on Control Panel.

    2. Navigate to the Network and Internet and click on Network and Sharing Center screen.

    Network Sharing Flush DNS

    3. Click on Change Adapter Settings and select your network type.

    Change Adapter Settings Flush DNS

    4. Right Click on the selected network type and click on Properties.

    5. Now, select Internet Protocol Version 4( TCP/ IPv4 ) and click on Properties.

    Select Internet protocol Version IPV4 Flush DNS

    6. Click on Use the following DNS Server addresses radio button.

    7. You can change your DNS Server Address to 8.8.8.8 and 8.8.4.4 and apply changes.

    Set DNS Value

    8. Try visiting your website now. If this solved your error, then you are all done. The problem was with your internet, and it is resolved now.

  • Flush DNS with Command Prompt
  • 1. First of all, type cmd in the windows Run command module and open the command prompt ( admin ).

    Windows Run Flush DNS

    2. Use ipconfig /flushdns to clear the DNS cache on your browser. Wait for few seconds and you will see the confirmation for DNS resolver cache has been flushed.

    Commavd Prompt Flush DNS

    How to Flush DNS on Linux

    Open your terminal and execute the command: sudo service network-manager restart

    How to Flush DNS on Mac

    To flush DNS on this mac operating system, navigate to Application › Utilities › Terminal and enter the command: sudo killall -HUP mDNSResponder

    Method 4) Test with Different Device

    Try to load your website on a different device such as a different machine, different network, or a mobile device. If you still facing the problem, then you have to check for the issue whether it is locally or server-side.

    Method 5) Check Error Log

    One of the causes of the 504 Gateway Timeout error is the recent changes or updates you made to the website. The quickest way to find out is by checking the error log. By Default, WordPress sets the WP_DEBUG to false but you can enable error logs by adding the following lines to the wp-config.php file:
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );

    Once done, all generated entries will appear in the wp-contents/debug.log file.

    Debug Log

    WP_DEBUG_LOG is an associate to WP_DEBUG that causes all errors to be saved to a debug.log log file inside the /wp-content/ directory. It is useful if you want to review all notices later or need to view warnings generated off-screen.

    Note that this allows you to write to /wp-content/debug.log using PHP’s built-in error_log() function.

    Method 6) Check Plugins and Theme

    WordPress plugins and themes are less expected to cause a 504 Gateway Timeout error. The 504 Gateway Timeout error triggered only when a plugin or theme is making too many requests to the server. When you resolve a 504 gateway timeout error, it is recommended to check through your website plugins.

    Outdated, Cache plugins and the plugins with bad code are more prone to the 504 Gateway Timeout error. Hence it is important to disable all the plugins, and this will let you know if you’re following the right path or not.

    To disable all the WordPress plugins, either you can do this by bulk action or by changing plugins directory name in the wp-content folder.

    For Bulk Action

    Check all the plugins and select deactivate from the drop-down and click on apply button.

    Bulk Deactivate Plugin

    Changing Plugins directory name

    Navigate to the wp-content » Plugins and change the plugins folder name to something else like plugins-test-demo.

    Change Plugins Name

    If your site works fine when all plugins are off, the next step would be to locate which one causes the HTTP error 504. To do so, you have to rename the plugins folder back to its original name and try to disable them one by one.

    If all your plugins are working fine, then you have to check the error with the theme. Just deactivate your current theme and use the WordPress default theme. After switching your theme to the default WordPress theme, visit your website to see if it’s working.

    Method 7) Check CDNs

    If you are using a CDN service to serve your content faster then you should check if everything is okay. One of the most commonly used CDN is CloudFlare. The best approach to resolve the error is to contact your CDN support or disable it entirely. If you are turning it off rather than disabling, you have to wait for a couple of hours to get back your site.

    Method 8) Check Server Settings

    There are some more fixes available for the VPS Hosting users. If you are a VPS Hosting user, then you can try these fixes to get rid of 504 Gateway Timeout error. You can alter the server setting by increasing the limits of specific resources so that you can solve the error.

  • Apache
  • If you are on Apache Server, try to increase the default timeout value in httpd.conf file with Timeout 600 .

    You have to increase the max_execution_time limit in the php.ini file to bring the positive results with max_execution_time 300. Save the changes, restart the server, and check again.

  • Nginx
  • If you are using Nginx in your VPS then you should try to increase the following values in /etc/nginx/conf.d/timeout.conf:
    Proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;

    Increase the max_execution_time in php.ini: max_execution_time 300 . Restart the Nginx and try to reload the tab with the error.

    Method 9) Contact Support

    If you are still facing the error after implementing all the above solutions then you should contact your host provider. Tell them about each step you had made to fix the issue and provide as much information as possible to get rid of the error quickly.