How to Fix 504 Gateway Timeout Error in WordPress

How to Fix 504 Gateway Timeout Error in WordPress

A 504 gateway timeout means your server took too long to respond — the quickest fixes are increasing PHP execution time, disabling a slow plugin, or clearing server-level caching that’s stuck.

What Causes a 504 Error in WordPress

A 504 is different from most WordPress errors because it happens at the server or proxy level, before WordPress even fully loads. Common causes include:

  • A plugin or scriptrunning a slow, unoptimized database query
  • PHP execution timeset too low for a heavy task (large import, bulk update)
  • An overloaded server or reverse proxy(common on shared hosting)
  • A third-party API call(payment gateway, external widget) hanging

How to Fix 504 Gateway Timeout in WordPress

Step 1: Reload and Wait

Sometimes a 504 is a temporary server hiccup. Wait 30–60 seconds and reload before assuming it’s a deeper issue.

Step 2: Increase PHP Max Execution Time

Add this to your ‘.htaccess’ file (if using Apache):

  • ‘php_value max_execution_time 300’

Or add this to ‘wp-config.php’:

  • ‘set_time_limit(300);’

Step 3: Disable Resource-Heavy Plugins

Backup and import plugins, complex page builders, and analytics plugins are frequent culprits. Deactivate them one at a time and retest.

Step 4: Check for a Broken External API Call

If your theme or a plugin calls an external service (like a shipping rate API or a font CDN) and that service is down, WordPress will hang waiting for a response. Check your plugin’s settings for any external integrations you can temporarily disable.

Step 5: Clear All Caching Layers

Clear caching at every level — WordPress caching plugin, hosting-level cache (like LiteSpeed Cache or Varnish), and CDN cache (like Cloudflare) — since a stuck cache rule can also cause a 504.

Step 6: Contact Your Host About Server Resources

On shared hosting, 504 errors often mean you’ve hit a CPU or process limit. Ask your host to check server logs for resource throttling around the time the error occurred.

504 Error: Where the Problem Usually Sits

Layer Common Issue Fix
WordPress/PHP Slow plugin query or low execution time Raise max_execution_time, disable plugin
CDN / Proxy Cloudflare or reverse proxy timeout Clear CDN cache, check proxy timeout settings
Hosting Server CPU/process limit reached Ask host to raise limits or upgrade plan
External API Third-party service not responding Temporarily disable the integration

 

Prevention Tips

  • Keep plugins updated — many 504 issues get patched in newer releases
  • Use a caching plugin to reduce server load on high-traffic pages
  • Monitor uptime so repeated 504s are caught early, not just after complaints

Helpful Resources & Authority Links

Leave a Reply

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