+254725682556 +254725052660 info@ziprof.co.ke
Client Area

General Knowledge

How to Fix a 504 Gateway Timeout Error on Your Website

A 504 Gateway Timeout error means a server sitting in front of your website (a load balancer, reverse proxy, or CDN) sent a request to your hosting server and didn't get a response back in time. Unlike a 500 error, it usually isn't a broken script: it's a slow one, or a network hop that isn't reaching your site at all.

What Causes a 504 Gateway Timeout

A few things typically cause this error:

  • A PHP script or plugin that's taking too long to finish running (a heavy report, an import, a poorly optimized query).
  • A slow or locked database query.
  • Your website making a call to a slow or unresponsive external API or third-party service.
  • Your hosting account hitting its resource limits, so requests get throttled or queued.
  • A CDN or reverse proxy in front of your site (if you use one) that can't reach your hosting server at all, often because of a DNS or nameserver misconfiguration.

How to Fix a 504 Gateway Timeout Error

  1. Reload the page after a minute or two. If it only happens on one specific page (a checkout, a search, a big form submission), the problem is likely with that page's script rather than the whole site.
  2. If you recently installed or updated a plugin, theme, or custom script, deactivate or roll it back and check if the error clears.
  3. Check whether the slow page calls an external service (a payment gateway, an MPesa API, a shipping calculator, a weather widget). If that service is down or slow, your page will time out waiting for it.
  4. If a specific script genuinely needs more time to finish (a large file import, for example), increase the PHP execution time limit as described below.

Increasing PHP Execution Time in cPanel

  1. Log in to cPanel and open MultiPHP INI Editor under the Software section.
  2. Select your domain from the dropdown, then switch to the Editor Mode view.
  3. Find the max_execution_time value and raise it (for example, from 30 to 90 seconds).
  4. Click Save and reload the page that was timing out.

Increasing PHP Execution Time in DirectAdmin

  1. Log in to DirectAdmin and open Select PHP Version under the Extra Features or Advanced Features section.
  2. Click on the Options tab to see the editable PHP directives.
  3. Find max_execution_time and raise it, then click Save.
  4. Reload the page that was timing out to confirm the change took effect.
Raising the execution time limit only helps if a script genuinely needs more time to complete. If a script is stuck in a loop or waiting on a dead external service, it will still time out eventually, just later. Treat a longer limit as a fix for a slow-but-working process, not a substitute for finding the real cause.

If You're Using a CDN or Reverse Proxy

If your domain sits behind a CDN or reverse proxy, a 504 can also mean that service can't reach your hosting server at all. Check that your domain's nameservers or DNS records still point to the correct hosting server, and that nothing was changed recently. A misconfigured or stale DNS record is a common, easy-to-miss cause.

Still Seeing the Error?

If the error keeps happening across your whole site rather than one page, your hosting account may be hitting a resource limit rather than one script being slow. If you're not sure whether the problem is on your end or something wider, see Is Your Website Down for Everyone, or Just You? If it persists, reach out to support with the exact page URL and time the error occurred so it can be traced in the server logs.