Website support, maintenance and fixes for UK businessesCall 0208 088 8371info@websupportservices.co.uk

HomeWordPress errorsWordPress 504 Gateway Timeout: How to Fix It

WordPress 504 Gateway Timeout: How to Fix It

A 504 Gateway Timeout means a gateway or proxy did not receive a response from the upstream server within the allowed time. On WordPress, the slow component may be PHP, the database, a plugin, an external service or the origin server itself.

The message you might see

504 Gateway Timeout

Different wording, or a file path in the message? Paste it into our free error finder to see which plugin or theme it comes from.

What a 504 Gateway Timeout means in WordPress

A WordPress request can pass through several systems before the finished page reaches a visitor. A CDN or reverse proxy may contact the origin web server, which then passes dynamic requests to PHP and WordPress. A 504 occurs when a gateway waits for an upstream response and that response does not arrive in time.

This gives you a useful diagnostic distinction. A 502 normally means the gateway received an invalid upstream response or encountered a related upstream connection failure. A 504 specifically points to waiting too long for the next system to respond.

Before changing plugins, files, database settings or server configuration, take a full backup of the site files and database. Perform potentially disruptive tests on staging where possible.

Common causes of a WordPress 504 timeout

Slow PHP execution is a common place to investigate. A plugin can run an expensive database query, call an external API that responds slowly, process a large import or perform intensive work during a normal page request. WordPress scheduled events, backups and ecommerce operations can create similar pressure.

The database may also be involved. Lock contention, overloaded database resources, a very large or poorly indexed query, or a remote database connection problem can delay PHP long enough for the proxy to stop waiting.

Infrastructure can cause the same symptom. An overloaded origin server, exhausted PHP workers, network delays between a CDN and the origin, or proxy timeout settings may determine when visitors see the 504. Increasing a timeout before identifying the slow component can simply make visitors wait longer for the same failing request.

How to fix a 504 Gateway Timeout in WordPress

  1. Identify the scope. Test the home page, wp-admin and the specific action that failed. If only imports, searches, checkout requests or administrative jobs time out, focus on the code and database work behind those requests.
  2. Check recent changes. Roll back a plugin, theme, PHP-version or deployment change if the 504 started immediately afterwards.
  3. Check WordPress and PHP logs. WP_DEBUG_LOG can capture WordPress-level PHP errors when the request runs far enough to reach WordPress. Also inspect PHP, web server and proxy logs for slow requests, worker exhaustion, upstream timeouts or process termination.
  4. Isolate plugins. Disable recently changed or resource-heavy plugins first. If wp-admin cannot be reached, use SFTP or the hosting file manager to rename the relevant directory inside wp-content/plugins. Restore it once the test is complete.
  5. Check PHP resource limits. WordPress documentation notes that connection timeouts can occur when the site tries to do more than the server can manage. Memory limits and maximum execution time are relevant when logs specifically indicate those limits, but changes to php.ini should match what the hosting environment supports.
  6. Inspect database and external calls. Repeated delays on the same operation can indicate a slow SQL query or a request waiting on a remote API. A larger gateway timeout does not correct either root cause.
  7. Check the origin path. If a CDN or reverse proxy is present, confirm that the origin remains responsive and that networking, DNS and SSL settings between the layers are correct.

When to get help with a WordPress 504 timeout

Get technical help if the failure is recurring, logs show consistently slow PHP or database work, the site exhausts workers under ordinary use, or you cannot determine which layer is timing out. Long-running requests can require application profiling rather than another timeout increase.

Our Emergency Fix is £249 per incident with response within 2 working hours. For ongoing updates, backups and monitoring, care plans start at £59 a month.

Common questions

Answers to the questions we hear most about this.

What is the difference between a 502 and 504 error in WordPress?

A 502 indicates that a gateway received an invalid response from an upstream server or could not use that upstream connection. A 504 means the gateway did not receive the upstream response within the required time.

Can a slow WordPress plugin cause a 504 Gateway Timeout?

Yes. A plugin that performs slow database work, large imports or delayed external API requests can keep PHP busy until a proxy or gateway reaches its timeout.

Should I increase the PHP execution time to fix a 504?

Only when logs show that the PHP execution limit is the relevant constraint and the longer execution is legitimate. Increasing limits without finding the slow operation can hide an application, database or hosting problem.

Site down or showing an error?

Call us now. Emergency Fix is £149 with a response within 2 working hours, and no fix means no fee.

Get website support