WordPress 504 Gateway Timeout Error: Complete Guide to Fixes and Prevention
Last edited on November 28, 2025

The 504 Gateway Timeout error is one of the most frustrating issues a WordPress site owner can encounter. Your website suddenly becomes inaccessible, visitors bounce away, your SEO suffers, and you’re left scrambling to figure out what went wrong, all while losing potential customers and revenue.

The problem is that 504 errors can be deceptively complex. They might originate from your hosting provider, your DNS configuration, your WordPress plugins, your server timeout settings, or a dozen other places. The error message itself provides almost no useful information about which of these is actually causing the problem.

This comprehensive guide cuts through the confusion. You’ll learn exactly what causes 504 errors, how to diagnose them systematically, how to fix them, whether they’re client-side or server-side, and most importantly, how to prevent them from happening in the first place.

What Is the 504 Gateway Timeout Error?

What Is the 504 Gateway Timeout Error

The 504 Gateway Timeout is an HTTP status code that shows that there is a certain server-side communication error. On the Internet Engineering Task Force (IETF), the definition is specific:

“The 504 (Gateway Timeout) status code indicates that the server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request.”

In simpler terms: Your web server is trying to reach another server (an upstream server or resource) to complete a request, but that upstream server isn’t responding fast enough. After waiting a predetermined amount of time (usually 30-60 seconds), your server gives up and returns the 504 error to the visitor browser.

How 504 Errors Differ from Other Server Errors

The 504 is often confused with other HTTP error codes that indicate server problems:

Error CodeMeaningCause
503 Service UnavailableThe server can’t handle the requestServer overloaded or down for maintenance
504 Gateway TimeoutGateway didn’t receive a response from the upstream serverCommunication delay between servers
500 Internal Server ErrorGeneric server errorPHP error, server misconfiguration
502 Bad GatewayInvalid response from upstream serverUpstream server malfunction

The key distinction: A 504 means servers are trying to communicate, but one isn’t responding fast enough. A 503 means the server itself is unavailable. A 502 means the upstream server sent an invalid response.

504 Error Variations

The 504 error appears in different formats depending on your browser, operating system, and web server software:

  • Error 504
  • HTTP Error 504
  • HTTP 504 — Gateway Timeout
  • HTTP Error 504 — Gateway Timeout
  • Gateway Timeout Error
  • 504 Error
  • Gateway Timeout (504)
  • 504 Gateway Timeout
  • 504 NGINX Gateway Timeout
  • NGINX 504 Gateway Timeout
  • 504 Bad Gateway

Regardless of wording variations, they all indicate the same underlying issue: the server didn’t receive a timely response from an upstream server.

What Causes 504 Gateway Timeout Errors?

Before you can fix a 504 error, you need to understand what causes it. Five hundred four errors originate from both client-side and server-side issues, though the vast majority are server-related.

Server-Side Causes (Most Common)

The most common cause is simple: the upstream server (or another server your WordPress site depends on) is too slow to respond. This might be:

  • Your application server is processing a complex database query
  • A third-party API (payment processor, email service, shipping provider) is responding slowly
  • Your hosting provider’s server is experiencing issues
  • DNS resolution delays

Server Overload and Resource Constraints

When your server receives too many requests simultaneously, it can’t process them all within the timeout window:

  • Traffic spikes exceeding server capacity
  • Insufficient server memory or CPU resources
  • Too many PHP processes are running simultaneously
  • Database running out of available connections

Insufficient PHP Workers

The PHP-FPM (FastCGI Process Manager) pool has a limited number of “worker processes” that handle requests. When all workers are busy, new requests queue up and may timeout:

  • Default PHP-FPM is often configured with too few workers
  • Resource-heavy plugins or themes are consuming workers unnecessarily
  • No horizontal scaling to distribute the load

Incorrect Timeout Configuration

Your server timeout settings might be too restrictive:

  • PHP execution time limit too short (default 30 seconds)
  • NGINX proxy timeout is too short
  • Apache timeout setting is too aggressive
  • The database connection timeout is too low

Corrupted or Inefficient Database

A poorly optimized WordPress database can cause queries to take excessive time:

  • Thousands of post revisions and trash items
  • Unoptimized database queries from poorly coded plugins
  • Missing database indexes
  • Large database without regular cleanup

Faulty or Resource-Heavy Plugins

Problematic WordPress plugins can consume excessive server resources or timeout:

  • Poorly coded plugins with inefficient database queries
  • Plugins with memory leaks or infinite loops
  • Security plugins with overly restrictive rules are blocking legitimate requests
  • Backup plugins attempting to back up during high-traffic periods
  • Caching plugins are misconfigured or incompatible with your theme

CDN and DNS Issues

Your Content Delivery Network or DNS configuration might be misaligned:

  • CDN misconfiguration is causing requests to fail
  • CDN IP addresses are not allowed on your firewall
  • DNS propagation issues after DNS changes
  • Stale DNS cache providing incorrect server information

Firewall and Security Blockages

Overly restrictive security settings can block legitimate traffic:

  • Web Application Firewall (WAF) rules are blocking requests
  • IP allowlisting is too restrictive
  • DDoS protection rules were incorrectly triggered
  • Security plugins are blocking legitimate requests

Upstream Server Failure

The remote server or service your WordPress site depends on might be completely down:

  • The payment processor API is completely unavailable
  • The email delivery service is experiencing an outage
  • Third-party WooCommerce integration is broken
  • External API used by a critical plugin offline

Client-Side Causes (Less Common)

While most 504 errors are server-side, sometimes client-side issues create the appearance of a 504 error:

Network Connectivity Issues

  • Temporary loss of internet connection
  • The VPN server is unable to reach your website’s server
  • Proxy server misconfiguration
  • ISP routing problems

Outdated DNS Cache

Local DNS cache on your computer contains stale information:

  • Recent DNS changes are not reflected in the local cache
  • Corrupted DNS cache entries
  • Pointing to the wrong server IP address

Browser Cache Issues

Cached data in your browser might interfere with requests:

  • Corrupted browser cache causing malformed requests
  • Expired cache entries are being served
  • Browser extensions are interfering with requests

How to Fix the 504 Gateway Timeout Error:

How 504 Errors Differ from Other Server Errors

Troubleshooting a 504 error requires systematic testing to isolate whether the problem is client-side or server-side. Work through these steps in order, testing after each change to see if the error resolves.

Initial Diagnostics (Try These First)

Wait and Reload the Page

There are cases when a 504 error is momentary, a transient glitch in the communication between servers which is resolved by itself.

What to do:

  • Wait 2-3 minutes and try again
  • Press F5 to refresh your browser (soft refresh)
  • Press Ctrl+F5 (Windows) or Cmd+Shift+R (Mac) to hard refresh, clearing cached data
  • Try accessing different pages on your site

If the error disappears, no further action is needed. If it persists, continue troubleshooting.

Try a Different Browser

Sometimes browser-specific issues cause 504 errors:

What to do:

  • Try the same URL in a different browser (Chrome, Firefox, Safari, Edge)
  • Try in Incognito/Private mode (bypasses browser extensions and cache)
  • If it works in a different browser, the issue is browser-related

If it works in another browser:

  • Clear your primary browser’s cache and cookies
  • Disable browser extensions one by one to identify the culprit

Try a Different Device

Device-specific issues might be causing the error:

What to do:

  • Try accessing your site on a different device (phone, tablet, laptop)
  • Use a different network (mobile hotspot instead of home WiFi)
  • Try from a completely different location with a different ISP

If it works on a different device, the problem is with your original device or network connection.

Client-Side Troubleshooting

Disable Your VPN

VPN services sit between your device and the internet, and sometimes VPN servers can’t communicate properly with your hosting server:

What to do:

  • Disable your VPN service temporarily
  • Try accessing your website again
  • If the error disappears, contact your VPN provider

If using a VPN is essential:

  • Try switching to a different VPN server location
  • Contact your VPN provider to allow your hosting server IP

Disable Browser Extensions

Browser extensions can interfere with website loading:

What to do:

  • Open your browser in Incognito/Private mode (disables extensions)
  • Test if your website loads without the 504 error
  • If it works in Incognito mode, disable extensions one by one.

To identify the problematic extension:

  • Go to your browser’s extension settings
  • Disable all extensions
  • Re-enable them one at a time
  • Test your website after each re-enablement
  • When the 504 error reappears, you’ve found the culprit

Check Your Proxy Settings

Proxy servers can interfere with website access:

Windows:

  1. Press Windows + R
  2. Type “inetcpl.cpl” and press Enter
  3. Go to the Connections tab
  4. Click LAN Settings
  5. Uncheck “Use a proxy server for your LAN.”
  6. Click OK
  7. Restart your browser and test

Mac:

  1. Go to System Preferences > Network
  2. Click Advanced
  3. Select the Proxies tab
  4. Uncheck all proxy options
  5. Click OK
  6. Restart your browser

Flush Your DNS Cache

A stale DNS cache can cause your computer to connect to the wrong server:

Windows:

  1. Press Windows + R
  2. Type cmd and press Enter
  3. Type ipconfig /flushdns and press Enter
  4. You’ll see “Successfully flushed the DNS Resolver Cache.”
  5. Close the command prompt and test your website

Mac:

  • For macOS Sierra and above: sudo killall -HUP mDNSResponder
  • For macOS Yosemite (10.10-10.10.3): sudo discoveryutil mdnsflushcache
  • For macOS Mavericks, Mountain Lion, Lion: sudo killall -HUP mDNSResponder
  • For macOS Snow Leopard: sudo dscacheutil -flushcache

Linux:
Open a terminal and run: sudo systemd-resolve –flush-caches

Change Your DNS Servers

Your current DNS servers might be slow or misconfigured:

What to do:

  • Try changing to Google public DNS: 8.8.8.8 and 8.8.4.4
  • Or try Cloudflare’s DNS: 1.1.1.1 and 1.0.0.1

To change DNS on Windows:

  1. Go to Settings > Network & Internet > WiFi
  2. Click Change adapter options
  3. Right-click your connection and select Properties
  4. Select Internet Protocol Version 4 (TCP/IPv4)
  5. Click Properties
  6. Select “Use the following DNS server addresses.”
  7. Enter the new DNS servers
  8. Click OK and test

To change DNS on Mac:

  1. Go to System Preferences > Network
  2. Select your connection and click Advanced
  3. Go to the DNS tab
  4. Click the + button and enter new DNS servers
  5. Click OK

Server-Side Troubleshooting

If client-side fixes don’t resolve the issue, the problem is on your server.

Check Your Server Status

Verify your server is actually running:

What to do:

  • Contact your hosting provider to confirm server status
  • Check your hosting control panel (cPanel, Plesk) for notifications
  • Check the hosting provider’s status page for reported issues
  • Confirm your hosting account isn’t suspended or overdue

Check the Error Logs

Your server error logs reveal specific issues causing the 504:

For Cloudways customers:

  1. Go to Application Settings > Monitoring
  2. Select Logs > Error Logs
  3. Review recent error messages for patterns

For cPanel users:

  1. Go to cPanel > Logs
  2. Select Error Log
  3. Look for PHP errors or timeout messages

For command line access:

tail -f /var/log/apache2/error.log        # Apache errors
tail -f /var/log/nginx/error.log          # NGINX errors
tail -f /var/log/php-fpm.log              # PHP-FPM errors

Check Your PHP Timeout Settings

PHP scripts exceeding their execution time limit cause 504 errors:

Increase PHP execution time via .htaccess:

If your server uses Apache, edit your .htaccess file:

php_value max_execution_time 300
php_value max_input_time 300
php_value memory_limit 256M

Increase PHP execution time via php.ini:

  1. Locate your php.ini file (usually in /etc/php.ini)
  2. Find the line max_execution_time = 30
  3. Change it to max_execution_time = 300 (or higher)
  4. Save and restart PHP-FPM: sudo service php-fpm restart

Increase timeout on NGINX:

Edit your NGINX configuration file (/etc/nginx/nginx.conf):

http {
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
    fastcgi_read_timeout 300;
}

Restart NGINX: sudo service nginx reload

Increase PHP-FPM timeout:

Edit your PHP-FPM pool configuration (/etc/php/[version]/fpm/pool.d/www.conf):

request_terminate_timeout = 300

Restart PHP-FPM: sudo service php[version]-fpm reload

Disable Your CDN Temporarily

A misconfigured or overloaded CDN might cause 504 errors:

What to do:

  1. Log in to your CDN provider (Cloudflare, Sucuri, etc.)
  2. Temporarily disable or bypass the CDN
  3. Access your website directly (use your IP address to bypass DNS)
  4. Test if the 504 error still occurs

If the error disappears:

  • Your CDN was causing the issue
  • Contact your CDN provider for assistance
  • Check CDN configuration for errors
  • Verify your Origin server IP is correct in CDN settings

To bypass Cloudflare temporarily:

  1. Go to the DNS tab
  2. For each record, set to DNS Only (gray cloud)
  3. Test your site
  4. Switch back to Proxied (orange cloud) once resolved

Deactivate All WordPress Plugins

Problematic plugins are a common 504 cause:

Via WordPress dashboard (if accessible):

  1. Go to Plugins > Installed Plugins
  2. Check the box at the top next to “Plugin.”
  3. Select Bulk Actions > Deactivate
  4. Click Apply
  5. Test your website

Via FTP/File Manager (if dashboard is inaccessible):

  1. Connect to your site via FTP or File Manager
  2. Navigate to /wp-content/
  3. Rename the plugins folder to plugins-disabled
  4. Test your website (all plugins are now disabled)
  5. If the error is gone, rename the folder back to plugins
  6. Deactivate each plugin individually to find the culprit

To identify the problematic plugin:

  1. Create a new folder in /wp-content/ called plugins-test
  2. Move one plugin at a time from plugins to plugins-test
  3. Test your site after each plugin movement
  4. When the 504 returns, you’ve found it

Switch to a Default WordPress Theme

A faulty theme can cause 504 errors (though less common than plugins):

What to do:

  1. Go to Appearance > Themes
  2. Activate the default WordPress theme (Twenty Twenty-Three or Twenty Twenty-Four)
  3. Test your website

If the error disappears:

  • Your theme has an issue
  • Contact your theme developer
  • Consider using a different theme
  • Check for theme updates

Check Your .htaccess File

A corrupted or misconfigured .htaccess file can cause 504 errors:

What to do:

  1. Connect via FTP or File Manager
  2. Navigate to your WordPress root directory
  3. Find the .htaccess file
  4. Create a backup: rename it to .htaccess.backup
  5. Test your website

If the error disappears:

  • Your .htaccess file was causing the issue
  • Regenerate the .htaccess file:
    • Go to Settings > Permalinks in the WordPress dashboard
    • Click Save Changes (without changing anything)
    • WordPress will regenerate a fresh. htaccess

If the error persists:

  • Restore your original .htaccess
  • The issue is elsewhere

Clean Up Your WordPress Database

A bloated database can slow response times enough to trigger 504 errors:

What to do:

  1. Go to Tools > Site Health (WordPress 5.2+)
  2. Check for database issues
  3. Use a database optimization plugin like WP-Optimize or Optimole
  4. Consider manually:
    • Deleting post revisions: thousands of old versions slow queries
    • Emptying trash: permanently delete trashed posts and pages
    • Removing spam comments
    • Cleaning orphaned metadata

Manual database cleanup via phpMyAdmin:

Remove post revisions:

DELETE FROM wp_posts WHERE post_type = 'revision';

Empty trash:

DELETE FROM wp_posts WHERE post_status = 'trash';

Remove spam comments:

DELETE FROM wp_comments WHERE comment_approved = 'spam';

Check for Firewall Blocks

Your hosting firewall might be blocking legitimate traffic:

What to do:

  1. Temporarily disable your WAF (Web Application Firewall)
  2. Temporarily disable IP allowlisting rules
  3. Temporarily disable DDoS protection
  4. Test your website

If the error disappears:

  • Your firewall rules were too restrictive
  • Allow legitimate IPs
  • Adjust firewall rules to be less aggressive
  • Contact your hosting provider for firewall configuration help

Check DNS Propagation

Recent DNS changes might not have fully propagated:

What to do:

  1. Use a DNS checker tool (MXToolbox, What’s My DNS, DNS Checker)
  2. Look up your domain to see the current DNS propagation
  3. Verify all nameservers point to your hosting provider
  4. Check that DNS changes propagated globally (takes 24-48 hours)

If DNS propagation is incomplete:

  • Wait for changes to fully propagate
  • Contact your DNS provider
  • Verify nameserver updates were saved correctly

Contact Your Hosting Provider

If none of the above fixes resolve the issue, contact your hosting provider:

What to tell them:

  • When the 504 error started
  • What pages/URLs are affected
  • Error log contents (attach if possible)
  • Steps you’ve already taken
  • Whether this is a new site or has recently changed

What they can check:

  • Server load and resource usage
  • Network connectivity to upstream servers
  • Server configuration and timeout settings
  • Firewall rules and IP blocks
  • DNS records and propagation
  • Third-party service connectivity

Conclusion:

The 504 Gateway Timeout error is frustrating, but it’s fixable. By systematically working through client-side diagnostics, then server-side troubleshooting, you can identify and resolve nearly any 504 error.

But the real key is prevention. By choosing quality hosting, maintaining your WordPress installation, monitoring actively, implementing caching, and planning for growth, you can virtually eliminate 504 errors from your website.

About the writer

Hassan Tahir Author

Hassan Tahir wrote this article, drawing on his experience to clarify WordPress concepts and enhance developer understanding. Through his work, he aims to help both beginners and professionals refine their skills and tackle WordPress projects with greater confidence.

Leave a Reply

Your email address will not be published. Required fields are marked *

Lifetime Solutions:

VPS SSD

Lifetime Hosting

Lifetime Dedicated Servers