Account

Error guide / 504 Gateway Timeout

How to fix a 504 Gateway Timeout error

504 Gateway Timeout appears when one server waited for a response from another and did not get it within the allotted time. A 502 means the response came back broken; with a 504 it arrived too late. It usually means that something on the site runs far too slowly.

Check your site

>

What causes it

The usual cause is a slow backend: heavy database queries, long-running scripts, an overloaded server or an external service that answers with a delay.

How to fix it

  1. Refresh the page after a minute. A one-off timeout can come from a temporary spike in load.
  2. Find the slow spots: heavy database queries, large imports or loops in the code.
  3. Turn off heavy plugins one at a time to see which one drags out the response.
  4. Turn on caching of pages and the database to reduce the load on the server.
  5. Check external calls such as APIs or payment gateways. If they hang, the response time grows.
  6. Raising max_execution_time alone rarely helps: a 504 comes from the timeout of the gateway in front of PHP (a proxy, FastCGI or a CDN), so fix the cause of the slowness first, and on a shared host ask support about that timeout.

Related errors