What a 504 gateway timeout means
A 504 gateway timeout, also called a 504 gateway error, is HTTP 504. The front server closed the request because the machine behind it never sent an HTTP reply before the timer ran out. The browser did reach a server. The work behind that server did not finish.
- HTTP 504 means the gateway stopped waiting because no upstream reply arrived.
- The browser reached a front server. The timer that fired sits on the hop behind it.
- More seconds help a slow job that would have finished. They do not help a loop.
That is not a crash and not a block. A script that dies mid-request is a different code. Adding time only helps when the job would have completed. A loop that never returns will still show a 504, only later.
How a 504 differs from a 502 and a 503
Match the code before you change a setting. A 502 means a reply came back and the proxy could not use it. A 503 means the server is refusing work for now.
The 503 service unavailable guide covers that refusal. A 500 means the script started and crashed, which the 500 error guide covers. A 403 is a deliberate refusal, covered in the 403 forbidden fix.
A 504 is only the wait. Use the row that matches the code you actually see, then stop.
| Code | What the proxy saw | What to do next |
|---|---|---|
| 504 Gateway Timeout | No HTTP reply before the timer | Read the error log. Raise a limit only if a script is slow. |
| 502 Bad Gateway | A reply arrived and was unusable | The upstream process died or spoke garbage. Inspect that process. |
| 503 Service Unavailable | The server refused the work | Check limits or maintenance. A longer timer will not help. |
| 500 Internal Server Error | The script started and crashed | Follow the log line on the 500 guide. |
| 403 Forbidden | The server refused on purpose | Fix permissions or the deny rule. A timeout change will not help. |

How to tell if a 504 is your network or your site
If the page loads for someone else, the 504 is on your path. Refresh once. Open a private window. Try a phone on mobile data, with any VPN or proxy turned off. If it loads there, stop editing the server and clear the cache on the device that failed.
If two networks show the same 504, the site is the cause. In cPanel open Metrics, then Errors, and reload the URL once. The new line says whether PHP ran long or a script died.
If Errors stays empty, and a plain HTML file in the same account also 504s, the wait is in the proxy or the web server, not in one PHP script.
How to raise PHP max_execution_time for a 504
On shared hosting, the usual 504 is PHP still working when the gateway stops waiting. Raise the limit only after Errors names a slow script. Then reload that same URL.
- Open cPanel, then Software, then MultiPHP INI Editor, and select the domain that returned the 504.
- Set max_execution_time to 300. A stock php.ini uses 30 seconds, which is too short for an import or a backup in the browser.
- If the log says the allowed memory size was exhausted, set memory_limit to 256M. Leave memory alone when the log does not mention it.
- Save, then reload the URL that timed out. It is fixed when the page appears and Errors adds no new timeout line.
- If MultiPHP INI Editor is missing, do not add php_value lines and hope. On PHP-FPM those .htaccess lines often never apply. Email the log line instead.
More seconds will not fix a loop or an API that never answers. If the 504 remains at 300 seconds, a lower limit in PHP-FPM or the web server is still cutting the request.
Shared hosting hides those files. A VPS is where you can edit them.
How to raise Nginx and Apache timeouts on a VPS
Edit these timers only on a VPS or dedicated server you administer. Shared hosting does not give you nginx.conf. Change the timer the site actually uses, test the config, then reload once.
- Nginx in front of another app: set proxy_read_timeout 300s; in the location that proxies the site. Run nginx -t and reload only if the test passes.
- Nginx with PHP-FPM: set fastcgi_read_timeout 300s; in the PHP location. proxy_read_timeout does not cover FastCGI.
- Apache: set Timeout 300. If Apache proxies to another process, also set ProxyTimeout 300. Test the config before the restart.
- PHP-FPM on either server: set request_terminate_timeout to 300 seconds in the pool file. A shorter pool timer still kills the script.
It worked when the slow URL returns the page. If nginx -t fails, undo the edit. Do not reload a broken file.
How plugins, cron jobs and APIs trigger a 504
A plugin, a scheduled job, or a call to another service can hold PHP until the gateway gives up. The log names the file. A 504 with no file name is not a reason to keep adding minutes.
- In File Manager, rename wp-content/plugins to plugins-off and reload. If the 504 clears, rename the folder back and turn plugins on in halves until the error returns. The last half holds the slow plugin.
- A backup or a product import in the browser will 504 when it outlasts the limit. Move that job to the host cron, or ask support to run it, instead of keeping the tab open.
- An outside API that never answers needs a shorter wait inside that plugin. A longer gateway timer only ties up PHP workers. The log line usually names the host it called.
When Cloudflare shows a 504 gateway timeout
A Cloudflare 504 page means the edge waited and your origin sent nothing back. The proxy did not time out a fast origin. Error 524 is a different Cloudflare page: the connection opened, then the origin stayed quiet past Cloudflare's own limit.
Pause the proxy on that hostname only. If the site loads with the proxy off, the delay is between Cloudflare and the origin. Turn the proxy back on after the test. If the origin still returns a 504 with the proxy off, Cloudflare is not the cause. Return to the log and the PHP limit.
When a 504 needs a hosting support email
Email support@webji.services when the log stays empty, every site on the account 504s, or you are on shared hosting and cannot see the PHP-FPM timer. Include the domain, the time in IST, the full URL, and the newest line under Metrics, then Errors. Say whether a second network shows the same page.
The mailbox is staffed 24/7 in Hindi and English, and the average first reply is under 60 minutes. The office phone is not the line for this error. Account holders can send the same details to the ticket form at https://billing.webji.in/submitticket.php?step=2&deptid=10.
Frequently Asked Questions
What is a 504 gateway timeout error?
A 504 gateway timeout, also called a 504 gateway error, means a proxy waited for an upstream server and received no HTTP reply before its timer ended. The browser reached a front server. The work behind it did not finish in time. It is not a missing page and not a permissions block.
How do I fix a 504 error on my website?
Check that a second network sees the same 504. Then open cPanel, Metrics, then Errors. If the new line shows a slow PHP script, set max_execution_time to 300 for that domain and reload the same URL. If the line names a plugin file, disable plugins in halves. Stop when the URL loads.
Why does my site get 504 errors randomly?
A random 504 usually hits one slow job: a backup, a cron run, an import, or a call to an outside API. Other pages still load. Compare the error time with cron and backup logs. An account that refuses every request under load is more often a 503 than a 504.
What is the difference between 502 and 504?
A 504 means the proxy waited and received nothing. A 502 means a reply arrived and the proxy could not use it, often because the app process died. A 503 means the server is refusing work. A 500 means the script started and crashed. Follow the guide for the code you see.
Does Cloudflare cause 504 errors?
A Cloudflare 504 page means the edge waited and your origin sent no reply. Cloudflare did not time out an origin that answered quickly. Error 524 is Cloudflare's own timeout page. Pause the proxy on that hostname. If the origin then loads, the delay is between Cloudflare and the server.
How do I increase PHP timeout in cPanel?
Open cPanel, Software, then MultiPHP INI Editor. Select the domain, set max_execution_time to 300, and save. Reload the URL that timed out. If the 504 remains, PHP-FPM or the web server may be stopping the request sooner. That timer is not in the INI editor. Email the log line.
Is a 504 gateway timeout my fault?
If the site loads in a private window, on mobile data, or for another person, the fault is your browser cache, VPN, or proxy. If every test shows the 504, including a second network, the fault is the site or the server in front of it, not your laptop.
Will a 504 gateway timeout fix itself?
A single 504 during a short overload can clear when you refresh. If the same URL fails again after a minute, it will not clear on its own. A script, a query, or a timer is still too slow. Read the newest error line and change that cause.

