When visitors open your website and see “502 Bad Gateway” or “504 Gateway Timeout”, two servers tried to talk to each other to load your WordPress page—and the backend server failed to answer properly.
Whether you see an nginx gateway screen, a cPanel proxy error, or a Cloudflare 502/504 banner, follow these step-by-step fixes to restore your site.
Is Free Hosting Holding Your Website Back?
Free hosting is great for testing, but strict CPU, inode, and Entry Process limits can knock your site offline once Google starts indexing your pages. Run our 60-second check to see what your site actually needs:
502 Bad Gateway vs 504 Gateway Timeout: What’s the Difference?
- 502 Bad Gateway: Your front-end proxy (Nginx, Apache, or Cloudflare) passed the visitor’s request to PHP-FPM, and the PHP process crashed, restarted, or returned an invalid header.
- 504 Gateway Timeout: Your PHP-FPM or MySQL process didn’t crash, but it got stuck running a slow task (like a huge WooCommerce export or backup) for longer than the server’s 30–60 second timeout window.
Step 1: Check DNS & Restart Stuck PHP Processes
First, verify that your domain’s DNS A records haven’t drifted using our Website Host & IP Checker. If you use cPanel, open MultiPHP Manager and toggle your PHP version (for example, from PHP 8.2 to PHP 8.3 and back)—this forces cPanel to restart stuck PHP-FPM worker pools immediately!
Step 2: Raise `max_execution_time` & `WP_MEMORY_LIMIT`
If 504 timeouts happen when importing content or saving heavy Elementor pages, increase your PHP limits:
- Use our Free WordPress wp-config.php Generator to raise
WP_MEMORY_LIMITto256M. - In cPanel’s MultiPHP INI Editor, increase
max_execution_timefrom30to120or180seconds.
Step 3: Move Background Tasks Off Page Loads
When WordPress tries to run scheduled backups or RSS fetches during a visitor’s page request via virtual wp-cron.php, it often triggers a 504 Gateway Timeout. Move your cron tasks to a real system schedule using our Free cPanel Cron Job & wp-cron Builder.
Frequently Asked Questions (FAQ)
What is the difference between 502 Bad Gateway and 504 Gateway Timeout?
A 502 Bad Gateway means the reverse proxy (Nginx or Cloudflare) received an invalid or crashed response from the backend PHP server. A 504 Gateway Timeout means the backend server took too long to respond and the proxy closed the connection.
Can a WordPress plugin cause a 502 or 504 error?
Yes. Plugins that make slow external API calls, run unindexed MySQL queries, or exhaust PHP-FPM workers frequently cause 502 and 504 gateway errors on shared hosting.
How do I quickly test if a 502 error is caused by my browser or the server?
Run your domain through the free Website Host & IP Detector and DNS Checker at FreeHosting.live to verify live server reachability.
1 COMMENT
[…] shared hosting, unzipping 10 plugin updates at once often hits your CPU or I/O limit or triggers a 504 Gateway Timeout—killing the PHP script before it can delete […]
Comments are closed.