cPanel & Hosting How-Tos How to Fix a 504 Gateway Timeout Error
A 504 Gateway Timeout means a request took too long and the server stopped waiting. Unlike a 503 (unavailable), a 504 is about slowness — something ran long. Here’s how to fix it.
What causes a 504
- A slow script or database query that takes too long to return.
- Big imports, exports or backups running in the browser.
- A low PHP
max_execution_timecutting off a legitimately long task. - An external API or service the page waits on being slow.
- Resource limits slowing everything down under load.
How to fix it
1. For a normal page timing out — make it faster
If an ordinary page 504s, the answer isn’t a longer timeout, it’s less work:
- Enable full-page caching so most requests skip PHP entirely — see LiteSpeed Cache for WordPress.
- Use a modern PHP version — much faster.
- Deactivate heavy plugins and optimize slow database queries.
2. For a big task — raise the time limit sensibly
A large import, export or backup can legitimately take minutes. Raise max_execution_time (and memory) for that job — see increase PHP limits in cPanel. Better still, run big jobs in smaller batches so no single request runs long.
3. Run heavy jobs outside the browser
Large database work is safer via phpMyAdmin or a scheduled cron than through a browser tab that can time out — see import and export a MySQL database.
4. Check your resource usage
If the whole site is slow and timing out, you may be hitting limits. Open Resource Usage in cPanel — see understand your resource usage and the CPU and IO guides.
5. Rule out a slow external service
If the page calls an external API (payment, feed, remote font), a slow third party can cause the timeout. Test with that feature disabled.
Still timing out?
If genuine work keeps exceeding shared limits, a Managed VPS gives you more time and power per request. Your error logs and our site-down troubleshooting guide help pinpoint the slow step.
Every Web Hosting and WordPress Hosting plan at Genhost runs on fast NVMe with a PHP selector, so most 504s come down to caching and a newer PHP version.
Frequently asked questions
What does a 504 Gateway Timeout mean?
It means a request took too long to complete, so the server gave up waiting. The usual causes are slow scripts or database queries, big imports or backups, or an external service the page depends on being slow.
How is a 504 different from a 503?
A 503 means the server is temporarily unavailable or overloaded; a 504 means the request started but took too long to finish and timed out. 504 is about slowness; 503 is about availability.
Can I just raise the PHP time limit to fix a 504?
Raising max_execution_time helps a genuinely long task (a big import) finish, but if a normal page is timing out, the real fix is to make it faster — caching, a modern PHP version and optimized queries.