How to Fix the 504 Gateway Timeout Error in WordPress
19 min read
26 November 2026
By Aijaz Mughal
Key Takeaways
-
The “504 Gateway Timeout” occurs when a proxy server fails to get a response from another upstream server. It commonly happens due to resource limits and slow processes.
-
Issues such as high server load, plugin conflicts and database delays, as well as PHP execution limits, can cause a “504 Gateway Timeout”.
-
You need to increase the PHP execution time and check the website's server logs to solve this error. Also, make sure to disable problematic plugins.
-
Regularly maintaining your WordPress website with performance optimization and server monitoring can solve these frequent timeout issues. It keeps your website running efficiently.
What is a “504 Gateway Timeout” Error?
An HTTP Error 504 is a 5xx server side status code. It appears when a gateway and reverse proxy sends a request to another server. But it does not receive the expected response within its configured time limit.
A real example is a busy service restaurant drive-thru. The intercom receives your order before passing it to the kitchen. The kitchen represents the upstream server. If the kitchen takes too long to finish the order, the drive-thru system stops waiting as a result.
A similar process occurs during a “504 Gateway Timeout” error. The gateway remains connected to the upstream server. But the requested operation does not finish before the timeout period expires.
502 Bad Gateway vs. 504 Gateway Timeout Error
A “504 Gateway Timeout” error can look similar to a 504 because both can appear when a proxy is involved. The actual server behavior differs.
A 502 Bad Gateway happens when the gateway reaches the upstream server and receives an invalid response. The upstream service may have failed during the connection process. It can also return a response the gateway could not accept.
A "504 Gateway Timeout” shows that the gateway reached the upstream server. But it waited a lot for the requested operation to finish.
If you want it in simple terms, then a 502 mostly means the upstream server responded incorrectly. A 504 error in WordPress means the gateway stopped waiting. Because the response took too long.
Common Variations of a 504 Gateway Timeout Error
The wording can change depending on the hosting environment. Nginx, Apache, along with Cloudflare and other proxy services, may display a slightly different message.
Common versions include:
-
504 Gateway Timeout
-
HTTP Error 504
-
504 Gateway Time-out
-
HTTP 504
-
Nginx 504 Gateway Timeout
-
Gateway Timeout (504)
-
A blank page that shows HTTP status 504 in the browser Network panel
Web pages using Cloudflare will display an error page with the logo of Cloudflare. The "504 Gateway Timeout” error is an indication that the edge server was unable to get a response from the origin server. That too, within the allowed time frame.
What Causes the "504 Gateway Timeout”?
It really helps to understand what happens after someone requests a page. This is particularly helpful for fixing a "504 Gateway Timeout” Error in WordPress.
The request first goes to an edge service and web server. Nginx may then pass it to PHP-FPM, which processes the WordPress request. PHP can load WordPress files, together with executing plugin functions plus communicate with the database.
The process may become slow when PHP workers are kept occupied for too long. A database query can also delay the request. External API calls can create another delay if the remote service takes too long to respond.
Once the configured timeout is reached. The gateway stops waiting and the visitor then gets a “504 Gateway Timeout” response.
According to W3Techs. WordPress powers more than 43% of the websites globally. The platform depends mostly on PHP processing together with database activity. So, a bottleneck in either of these two can affect page requests.
Several issues can add up to a timeout:
-
Server Resource Exhaustion: RAM/CPU can reach their max capacity during traffic spikes. Scheduled WP Cron activity along with intensive security scans can also contribute to it.
-
PHP-FPM Worker Starvation: All available PHP FPM workers may remain busy with slow requests. New requests then wait until the gateway timeout is reached.
-
Slow Code or External API Requests: A plugin may wait for a payment gateway, CRM and another external service. Poorly configured wp_remote_get() requests can also extend processing time.
-
Short Server Timeouts: Nginx fastcgi_read_timeout or Apache Timeout settings may stop legitimate processes before completion.
-
Database Locking or Slow Queries: Missing indexes, together with large option tables or database locks, can delay PHP processing.
Research available through Google PageSpeed Insights shows that longer loading times increase the likelihood of mobile visitors leaving a page. A complete gateway timeout creates an even bigger usability issue. Because the requested page never arrives.
How to Fix a 504 Gateway Timeout as a Website Visitor
A "504 Gateway Timeout” error usually points toward the website's server rather than the visitor's computer. There are still a few local checks worth trying.
A browser may hold an older error response in its cache. DNS information can also become outdated. These issues can make a recovered site appear unavailable sometimes.
1. Perform a Hard Browser Refresh
A regular refresh may reuse locally stored information. So, you have to opt for the hard reset.
Press Ctrl + F5 / Ctrl + Shift + R on Windows. If you are running Google Chrome, Edge and Firefox
Press the Cmd + Shift + R combination on Mac. If you have Safari or Edge browser.
Verification: Check that the file request is fresh rather than your browser accessing it from local cache.
2. Check Whether the Website Is Down Globally
You can use an online status service to check the status of your sites. Like Down For Everyone Or Just Me or IsItDownRightNow. To check the website from external locations.
Enter your domain into the service before reviewing its status.
Verification: If external locations report that the website is available. Your connection may have a local DNS or possibly an ISP issue.
3. Flush Your Local DNS Cache
An outdated DNS record can also sometimes direct your computer to an old server address.
In Windows Command Prompt, type this:
ipconfig /flushdns
On macOS Terminal, use:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
You can then check the resolved address with:
nslookup aundigital.com
Verification: Confirm that the returned IP matches your current server address.
If these checks show that the website itself is returning an HTTP Error 504. The next stage involves the hosting environment.
How to Fix a 504 Gateway Timeout Error as a Website Owner
As a website owner, you have many privileges that can help you trace this problem and solve it. We have discussed several solutions below:
Solution 1: Check Server Resources and PHP-FPM Limits
Your server may start to time out if you have RAM and CPU utilization peaks. PHP-FPM can create another bottleneck. This happens when all available workers are already handling slow requests.
If you have SSH access, run:
# Check CPU, RAM and system load
htop
You can inspect active PHP-FPM processes with:
# View PHP-FPM processes
ps aux | grep php-fpm
If resource usage remains high. Review your PHP-FPM pool configuration.
A common location is:
/etc/php/8.2/fpm/pool.d/www.conf
Another possible location is:
/etc/php-fpm.d/www.conf
Depending on the server workload, the configuration may include:
; PHP-FPM process manager settings
pm = dynamic
pm.max_children = 50
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 500
Restart PHP-FPM after changing the configuration:
sudo systemctl restart php8.2-fpm
Replace 8.2 with the PHP version installed on your server.
Check the service status with:
systemctl status php8.2-fpm
Verification: The service should report active (running).
Solution 2: Increase Nginx or Apache Timeout Limits
Some of the WordPress operations require more processing time. A big WooCommerce import can take more time compared to a standard page request. Database migrations can also create similar delays.
A short timeout may terminate these processes before they finish.
For Nginx
The website configuration may be stored at:
/etc/nginx/sites-available/yourdomain.conf
Another common location is:
/etc/nginx/conf.d/default.conf
A PHP configuration can contain:
server {
listen 80;
server_name aundigital.com;
root /var/www/yourdomain/public_html;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
}
}
Test the Nginx configuration before applying it:
sudo nginx -t
Then reload Nginx:
sudo systemctl reload nginx
For Apache
The main Apache configuration may contain a Timeout directive:
TimeOut 300
Common configuration locations include:
/etc/apache2/apache2.conf
or:
/etc/httpd/conf/httpd.conf
For FastCGI configurations, review the proxy timeout as well:
SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost"
ProxyTimeout 300
Reload Apache after making changes.
Ubuntu or Debian:
sudo systemctl reload apache2
CentOS or RHEL:
sudo systemctl reload httpd
Verification: Repeat the operation that previously generated the timeout. If it remains active beyond the previous limit. The timeout setting may lead up to the problem.
Solution 3: Review PHP Execution and Memory Limits
Increasing the web server timeout does not automatically increase PHP's own limits.
Open the relevant php.ini file. A common PHP-FPM location is:
/etc/php/8.2/fpm/php.ini
You may also find a CLI configuration at:
/etc/php/8.2/cli/php.ini
Review settings such as:
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
post_max_size = 128M
upload_max_filesize = 128M
If you cannot edit php.ini. WordPress memory limits can sometimes be changed through wp-config.php.
Place the following before the line containing That's all, stop editing! Happy publishing.
define( 'WP_MEMORY_LIMIT', '512M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
Apache installations using mod_php may support these .htaccess settings:
php_value max_execution_time 300
php_value max_input_time 300
Verification: phpinfo() file that is temporary can show the active PHP configuration. Remove this file immediately after checking it. Because making the server info public is risky.
Solution 4: Isolate Problematic WordPress Plugins
A plugin can cause long PHP processes if its code performs an expensive operation. External API requests can create similar issues and delays.
Method 1: Use WP-CLI
If SSH access is available, move to the WordPress installation:
cd /var/www/yourdomain/public_html
List the installed plugins:
wp plugin list
Deactivate all plugins:
wp plugin deactivate --all
Check the website again after the deactivation.
Method 2: Rename the Plugin Directory
If WP-CLI is unavailable, SFTP or SSH can be used instead.
Open:
/wp-content/
Rename:
plugins
to:
plugins-deactivated
The directory structure will then resemble:
/wp-content/
├── themes/
├── uploads/
└── plugins-deactivated/
Renaming these directories disables the plugins disabled.
If the website starts working. Restore the original plugin names. You can then deactivate individual plugins to locate the source.
Verification: After each plugin change. Refresh the affected page and when the timeout disappears, then the last plugin disabled should be investigated further.
Solution 5: Check CDN and Proxy Configuration
A CDN or Web Application Firewall can sit between visitors plus the origin server. When that connection fails. The “504 Gateway Timeout” error may originate within the proxy layer.
Cloudflare can display various 504 responses. It also depends on where the request stops.
-
Cloudflare 504 Page: The edge service may have failed to establish an HTTP connection. Mostly with the origin.
-
Standard 504 Response: It did not receive the required response within the specified time period after reaching the origin.
Expert server administrators can break the proxy temporarily. By adding the origin IP to the local hosts file.
On macOS or Linux:
/etc/hosts
On Windows:
C:\Windows\System32\drivers\etc\hosts
Example:
192.0.2.100 aundigital.com www.aundigital.com
Use your actual origin IP instead of the example address.
Open the website through a clean private browser session. But after saving the change. If the origin works directly. Then investigate the proxy configuration and origin firewall.
Solution 6: Rebuild Corrupted .htaccess Rules
A damaged .htaccess file can possibly create rewrite requests repeatedly on Apache servers. Those requests can consume server resources before eventually producing a gateway timeout.
To test the file:
-
Connect through SFTP.
-
Locate /public_html/.htaccess.
-
Rename it to .htaccess-backup.
-
Create a new .htaccess file.
Use the standard WordPress rules:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule. /index.php [L]
# END WordPress
Verification: Open the WordPress dashboard. Go to Settings > Permalinks. Then select Save Changes. This refreshes the permalink configuration.
Solution 7: Inspect the WordPress Database
Slow database operations can keep PHP workers occupied. Large wp_options tables can add processing overhead. Missing indexes or database locks may create further delays.
Check Autoloaded Data in wp_options
WordPress can load autoloaded options during page requests. Excessive autoloaded data may increase the amount of information processed on each request.
Run:
SELECT SUM(LENGTH(option_value)) AS total_autoload_bytes
FROM wp_options
WHERE autoload = 'yes';
If the result is unusually large, identify the biggest entries:
SELECT option_name, LENGTH(option_value) AS option_size
FROM wp_options
WHERE autoload = 'yes'
ORDER BY option_size DESC
LIMIT 10;
Review stale transients along with other options left behind by removed plugins before deleting anything. Database changes should be made carefully. It is preferable to do this after creating a backup.
Repair Corrupted Tables
WordPress includes a database repair utility.
Add this line to wp-config.php:
define( 'WP_ALLOW_REPAIR', true );
Then open:
https://aundigital.com/wp-admin/maint/repair.php
Select Repair and Optimize Database.
Verification: Review query response times after the repair. WP-CLI can also help inspect database activity.
Solution 8: Review WordPress and Server Logs
A visible HTTP Error 504 rarely identifies the exact process responsible. Error logs can provide more useful information.
Enable WordPress debugging through wp-config.php:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
WordPress will record errors in:
/wp-content/debug.log
You can monitor the file through SSH:
tail -f /var/www/yourdomain/public_html/wp-content/debug.log
Review Nginx errors with:
tail -n 50 /var/log/nginx/error.log
For Apache:
tail -n 50 /var/log/apache2/error.log
For PHP-FPM:
tail -n 50 /var/log/php8.2-fpm.log
Look for messages such as upstream timed out or Connection timed out. These entries can help identify the request that remained open when the gateway stopped waiting.
How to Prevent the 504 Gateway Timeout Error
Fixing the immediate error is only part of the process. Regular maintenance can reduce the chance of similar problems returning.
1. Use Reliable Managed Infrastructure
Low-cost shared hosting can create resource limitations. Traffic spikes on another website sharing the same environment may affect available CPU resources.
Managed infrastructure gives businesses greater control over server resources. The right setup should reflect expected traffic together with application requirements.
2. Enable Persistent Object Caching
Redis or Memcached can store frequently requested database results in memory. This reduces repeated database work during page requests.
3. Schedule Database Maintenance
WP-CLI or scheduled cron jobs can help remove expired transients. Old post revisions can also be reviewed periodically.
4. Move Static Assets to a CDN
Large images, PDF files, CSS files, or JavaScript resources can consume bandwidth when served directly from the origin server.
Services such as AWS S3 or Cloudflare R2 can store static files. A CDN can then deliver those resources closer to visitors.
Data from HTTP Archive shows that images plus script assets represent a substantial portion of modern webpage transfer weight. Moving static resources away from the origin can leave more server capacity for dynamic PHP requests.
When Should You Contact Hosting Support or a WordPress Expert?
Even if the server settings are checked, a "504 Gateway Timeout” error can still persist. If plugin testing, together with database checks and PHP-FPM changes, does not resolve it. The problem could be deeper in the infrastructure. Repeated resource problems can also occur due to hardware failures and network routing failures can also prevent communication with the origin server. Requests may also be waiting for a longer period than expected due to database locks.
If you have a large website and WooCommerce store with UAE customers, frequent downtime can impact your revenue and search rankings. A specialized WordPress development company can evaluate your website setup along with the server environment.
Final Words
A "504 Gateway Timeout” error in WordPress means a request has taken longer than the gateway is prepared to wait. The underlying cause can sit within PHP-FPM, the database, a plugin, or the server configuration.
Start by checking resource usage. Review PHP-FPM activity alongside server timeout settings. If those areas appear normal, test plugins before examining database performance plus application logs.
Once the immediate issue is fixed, ongoing monitoring can help identify resource problems earlier. Businesses running busy WordPress websites can benefit from professional development support together with regular maintenance. A stable infrastructure gives the website more room to handle traffic without repeated gateway failures.
Frequently Asked Questions
Q1. Does a "504 Gateway Timeout” error in WordPress Damage SEO Rankings?
A short outage does not normally cause lasting ranking damage. Repeated 504 responses can become more serious when search engine crawlers encounter them over an extended period.
If important URLs remain unavailable for too long, search engines may temporarily reduce their visibility or remove them from the index.
Q2. Can a Security Plugin Trigger a "504 Gateway Timeout” error in WordPress?
Yes. Security plugins can perform resource-intensive scans. Malware checks or automated backup tasks may also keep server resources occupied.
If these processes consume available CPU or PHP workers for too long, an HTTP Error 504 may appear.
Q3. Why Does the "504 Gateway Timeout” error Only Appear on WooCommerce Checkout Pages?
WooCommerce checkout pages require live processing. They handle session information, cart data plus payment-related requests.
Static blog posts may continue loading because they require less server-side processing. A slow database query or limited server capacity can therefore affect checkout without taking down every page.
Author
Aijaz Mughal is a digital marketing strategist, business growth advisor and Founder & Managing Director of Aun Digital. With more than 15 years of experience in the UAE market, he has worked across SEO, PPC, performance marketing, digital strategy, social media, project management and team leadership.Throughout his career, Aijaz has worked with leading brands including Emaar, Masdar, Honda, Leejam, Unilever, The Dubai Mall, Emerson, Moorfields and Yamaha, helping businesses develop effective digital strategies and achieve measurable growth.
Speak to an Expert





