Troubleshooting

How to fix a 504 Gateway Timeout error

A 504 Gateway Timeout means a proxy waited too long for the server behind it. Learn the causes on shared hosting, CDNs and VPS servers, and how to make slow requests finish.

BeginnercPanel hosting2 min read

A 504 Gateway Timeout error means a gateway – a CDN, a load balancer or the web server in front of your application – forwarded the request and gave up waiting for a reply. The backend is not necessarily down; it is too slow for that request. Fixing a 504 means finding what makes the request slow, or moving that work out of the web request.

Before you start

  • Note which URLs return 504 – every page, or only heavy ones like imports, reports or checkout.
  • Check whether a CDN such as Cloudflare is in front (its timeout shows as error 524 instead).

Common causes of a 504 error

  • Slow PHP scripts – imports, exports, report generation, image processing.
  • Slow database queries on large tables or locked tables.
  • External API calls that hang without a timeout.
  • Resource limits making every request crawl.
  • Short proxy timeouts on a VPS (Nginx proxy_read_timeout or fastcgi_read_timeout).

How to fix it on cPanel hosting

  1. Identify the slow request in cPanel → Metrics → Raw Access and the error log.
  2. Check resource usage in Metrics → Resource Usage; frequent CPU or I/O limits slow everything. See I/O limits and slow websites.
  3. Move long tasks to cron or WP-CLI instead of running them from a browser.
  4. Optimise the site: enable LiteSpeed Cache, remove heavy plugins and clean the database. Our slow website guide lists the checks.
  5. Add timeouts to outgoing API calls in your code or plugin settings.

How to fix it on a VPS

  1. Check the backend is healthy: PHP-FPM status, free workers, CPU and memory.
  2. Find slow queries with the MySQL slow query log.
  3. Raise proxy timeouts only for specific long endpoints, not site-wide. See Nginx 504 Gateway Timeout.

Note: Increasing timeouts hides slowness. Visitors will not wait 5 minutes for a page; make the request faster or run it in the background.

FAQ

Is a 504 error a server outage?

Usually not. The server is up, but one request takes too long.

What is the difference between 504 and 524?

524 is Cloudflare's own timeout after 100 seconds; 504 comes from a gateway at your host or server.

Does the task continue after a 504?

Often yes. Check the result before rerunning it.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.