21+ years in hosting · Jaipur, India · INR billing with 18% GST · 24/7 email support
Blog · WebJi® India

How to Fix a 504 Gateway Timeout Error

Quick answer

A 504 Gateway Timeout means a proxy or CDN waited for the server behind it and got no reply before its timer ran out. First check a second network, then read the error log for the slow script. On cPanel, raise max_execution_time in MultiPHP INI Editor; on a VPS, raise the Nginx, Apache or PHP-FPM timeout.

For site owners and developers facing 504 errors on WordPress, cPanel, Nginx, Apache or behind Cloudflare, with the fix for each layer.

✓ In business since 2005
✓ INR + GST billing
✓ 24/7 Email Support — avg reply < 60 min
GuideWebJi®
knowledge
Read time
5 min
Sections
8
Updated
14 Nov 2026
Written by
WebJi® team

What does a 504 Gateway Timeout error mean?

HTTP 504 Gateway Timeout means a front server — a proxy, load balancer or CDN — waited for the server behind it and received no reply before its timer ran out. Your browser did reach a server; the work behind that server did not finish in time.

It is not a crash and not a block. Extra seconds help a slow job that would have finished; they do not help a loop or an outside API that never answers. Find what is slow before raising any limit.

Default wait timers that commonly produce a 504
LayerSettingDefault
PHPmax_execution_time30 seconds
Nginx proxyproxy_read_timeout60 seconds
Nginx with PHP-FPMfastcgi_read_timeout60 seconds
Apache 2.4Timeout60 seconds
Cloudflare proxyOrigin response wait (shows error 524)100 seconds

The shortest timer in the chain wins, so a 300-second PHP limit behind a 60-second proxy still returns a 504 at one minute.

How is a 504 different from 502, 503 and 500 errors?

A 504 is only a wait that ran out; a 502 means a reply arrived but was unusable, a 503 means the server refused work, and a 500 means the script started and crashed. Match the code before you change a setting, because each has a different fix.

Server error codes and where to look
CodeWhat the proxy sawNext step
504 Gateway TimeoutNo reply before the timerFind the slow script or call; raise a limit only if the job is legitimate
502 Bad GatewayA broken or empty replyThe upstream process died; see fixing a 502
503 Service UnavailableRefused for nowResource limits or maintenance; see fixing a 503
500 Internal Server ErrorScript crashedRead the log line; see 500 errors on cPanel

Is the 504 caused by your network or by the website?

If the page loads on another network, the 504 is on your path; if it fails on two networks, the site or its server is the cause. Test this first so you do not edit a server that is working.

  1. Refresh once, then open the URL in a private window.
  2. Try a phone on mobile data with any VPN or proxy turned off.
  3. If it loads there, clear the cache and proxy settings on the device that failed, and stop.
  4. If both fail, open cPanel → Metrics → Errors (or your server's error log), reload the URL once, and read the new line.
  5. If the log is empty and a plain HTML file on the same account also returns 504, the delay is in the proxy or web server, not in one PHP script.

How do you raise PHP max_execution_time on cPanel?

In cPanel open Software → MultiPHP INI Editor, choose the domain, set max_execution_time to 300 and save, then reload the URL that timed out. Do this only after the error log shows a legitimately slow script, such as an import or report.

  1. Open MultiPHP INI Editor and select the affected domain.
  2. Set max_execution_time to 300 (the default is 30 seconds).
  3. If the log mentions "Allowed memory size exhausted", also set memory_limit to 256M; otherwise leave memory alone.
  4. Save and reload the slow URL. It is fixed when the page appears and no new timeout line is logged.

On PHP-FPM, php_value lines in .htaccess are often ignored, so do not rely on them. If the 504 remains at 300 seconds, a shorter timer in PHP-FPM or the web server is still cutting the request, and on shared hosting that timer is set by the host. Checking PHP error logs shows where to find the right log.

How do you raise Nginx, Apache and PHP-FPM timeouts on a VPS?

On a server you administer, raise the timer that the site actually passes through — proxy_read_timeout or fastcgi_read_timeout in Nginx, Timeout and ProxyTimeout in Apache, and request_terminate_timeout in the PHP-FPM pool — then test the config before reloading. Shared hosting does not expose these files.

# Nginx proxying to an app (Node, Python, another server)
location / {
    proxy_pass http://127.0.0.1:3000;
    proxy_read_timeout 300s;
}

# Nginx with PHP-FPM (proxy_read_timeout does not apply to FastCGI)
location ~ \.php$ {
    fastcgi_pass unix:/run/php/php-fpm.sock;
    fastcgi_read_timeout 300s;
}

# Apache (httpd.conf or the vhost)
Timeout 300
ProxyTimeout 300

# PHP-FPM pool file, e.g. /etc/php/8.3/fpm/pool.d/www.conf
request_terminate_timeout = 300

Run sudo nginx -t or sudo apachectl configtest and reload only if the test passes; restart PHP-FPM after editing its pool. Adjust the socket path and PHP version to match your server. A KVM VPS gives you access to all of these files.

Which plugins, cron jobs and API calls cause 504 errors?

Most WordPress 504s come from one slow job: a backup or import running in the browser, a heavy cron task, or a plugin waiting on an outside API that does not answer. The error log usually names the file or host involved.

  • Find the plugin: with SSH run wp plugin deactivate --all, then reactivate plugins in halves until the 504 returns. Without SSH, rename wp-content/plugins to plugins-off in File Manager, test, and rename it back.
  • Long jobs: move backups and product imports to server cron instead of a browser tab; see replacing WP-Cron with a real cron job.
  • Outside APIs: a payment, shipping or SMS API that hangs needs a shorter timeout inside the plugin; a longer gateway timer only ties up PHP workers.
  • Random 504s: compare the error time with cron and backup schedules; one recurring job is the usual culprit.

What does a 504 or 524 error from Cloudflare mean?

A Cloudflare-branded 504 means Cloudflare's edge got no response from your origin, while error 524 means the connection opened but the origin took longer than Cloudflare's 100-second limit to reply. In both cases the slow part is your server, not Cloudflare.

To confirm, pause the Cloudflare proxy for that hostname (grey cloud) and load the site directly. If it loads quickly, look at the connection between Cloudflare and the origin, such as a firewall blocking Cloudflare's IP ranges. If the origin still times out, return to the log and the PHP limits. Turn the proxy back on after the test. Long reports or exports that need more than 100 seconds should run in the background and email the result.

When should you email hosting support about a 504?

Contact support when the error log is empty, every site on the account returns 504, or you are on shared hosting and the limit you need is not in the INI editor. Send the domain, full URL, time in IST, the newest error-log line, and whether a second network shows the same error.

WebJi® support is at support@webji.services, staffed 24/7 in Hindi and English with an average first reply under 60 minutes; account holders can also open a ticket in the client area. For general background on status codes, see HTTP status codes explained.

FAQ

Frequently asked questions

Will a 504 Gateway Timeout fix itself?

A single 504 during a brief overload can clear on refresh. If the same URL fails again a minute later, it will not fix itself: a script, query or timer is still too slow. Read the newest error-log line and fix that cause.

Is a 504 error my fault as a visitor?

Usually not. If the page loads on mobile data or for someone else, your browser cache, VPN or proxy is involved. If every network shows the 504, the problem is the website or its server.

Does a 504 error hurt SEO?

Brief, occasional 504s have little effect. If Googlebot sees 5xx errors for hours or days, it slows crawling and can drop affected URLs until they recover. Fix persistent timeouts quickly and check Search Console's crawl stats afterwards.

Why does only the WordPress admin show a 504?

Admin pages are not cached and often run heavy tasks such as plugin update checks, dashboards that call outside APIs, or large WooCommerce reports. Disable the dashboard widget or plugin making slow external calls, or raise the PHP limit for that job.

Default timers checked against Nginx, Apache, PHP and Cloudflare documentation · Reviewed by the WebJi® team, Jaipur, 15 November 2026.

WebJi® since 2005

Ready to get started with WebJi®?

Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.