Find cheap domain names for your website - namesilo.com
Namesilo Blog
Blog

How to Fix the 504 Gateway Timeout Error

NS
NameSilo Staff

6/12/2026
Share
A 504 Gateway Timeout error occurs when a server acting as a gateway or proxy fails to receive a timely response from the upstream server. This usually happens when a website's server is overloaded, executing a heavy database script, or struggling with insufficient PHP execution limits. To fix it, optimize your database, upgrade your server resources, or increase the PHP timeout limit.

What Is an Upstream Server?

Web requests pass through multiple layers:
Layer
Role
Browser
Sends request
Web server (Nginx/Apache)
Gateway, forwards to PHP
PHP-FPM
Executes code
Database (MySQL)
Returns query results
The 504 breakdown: Your web server forwarded a request upstream, and waited. It never got a reply within the time window. So it returned 504.
504 vs 502: A 502 means the upstream server returned an invalid response. A 504 means it returned no response at all, it ran out of time.

Root Cause 1: Server Resource Exhaustion

Shared hosting plans have hard CPU and memory caps enforced at the server level. NameSilo plans range from 2 CPU cores (Starter) to 6 CPU cores (Turbo). When your site hits that limit, PHP processes queue up waiting for CPU and incoming requests to time out before they're processed.
Common triggers: Traffic spikes, backup plugins running during peak hours, WooCommerce inventory syncs, and unoptimized database queries.
Check your usage first: cPanel → Metrics → Resource Usage → Dashboard. This shows real-time CPU, RAM, and entry process consumption against your plan limits. If you're consistently hitting the ceiling, an upgrade is required, not a config tweak.

Root Cause 2: PHP Execution Time Limits

PHP has a maximum execution time, when a script exceeds it, PHP terminates it and the web server returns 504. Default is typically 30-60 seconds on shared hosting.
Triggers: CSV imports, bulk image processing, large WooCommerce exports, and database migrations routinely exceed this.
How to increase it:
.htaccess (quickest):
php_value max_execution_time 300
php.ini:
max_execution_time = 300
In cPanel: MultiPHP INI Editor → max_execution_time → Set to 300.
300 seconds covers most heavy operations without opening your server to runaway scripts.

Implementation Steps: Diagnose and Fix

Step 1: Check Resource Usage cPanel → Metrics → Resource Usage → Dashboard. Note any metrics at their limit.
Step 2: Check Error Logs cPanel → Metrics → Errors. Look for PHP Fatal Error or timeout messages before the 504.
Step 3: Increase PHP Execution Time Use .htaccess: php_value max_execution_time 300.
Step 4: Handle Cloudflare Cloudflare adds its own 100-second timeout. Go to Cloudflare Dashboard → Network → Proxy Timeout to extend it, or temporarily pause Cloudflare to isolate whether the issue is origin or CDN.
Step 5: Optimize Heavy Queries cPanel → phpMyAdmin → identify slow queries. Add indexes to frequently-queried columns.
Step 6: Upgrade If Resource-Limited If Resource Usage shows consistent ceiling hits, upgrade your hosting plan.

Common Mistakes

Assuming permanent breakage: A 504 is often temporary. If a backup or cron job ran at that moment, the site recovers once the process completes.
Raising PHP timeout without checking resources: If CPU is the bottleneck, more time just makes it time out slower.
Forgetting Cloudflare's independent timeout: Cloudflare's 100-second limit triggers 524 errors even when your origin server is fine.

What This Means for You

NameSilo Hosting plans scale from Starter to Turbo. If Resource Usage shows consistent ceiling hits, upgrading from 2 to 6 CPU cores resolves most 504 patterns without any configuration changes.
Need a domain? Search available names at NameSilo.

Frequently Asked Questions

What causes a 504 Gateway Timeout? 
Server overload, slow queries, or PHP time limits exceeded.
How do I fix a 504 error in WordPress? 
Increase max_execution_time and check cPanel resource usage.
Is a 504 error my fault or the server's? 
Usually the server, under-resourced or misconfigured.
How do I increase PHP execution time? A
dd php_value max_execution_time 300 to .htaccess.
Why does Cloudflare show a 504 error? 
Origin server didn't respond within Cloudflare's timeout.
Does clearing cache fix a 504 error? 
No. Cache addresses content issues, not server timeouts.
What is the difference between 502 and 504? 
502 = invalid response received. 504 = no response in time.
How do I check my server error logs?
cPanel → Metrics → Errors.
ns
NameSilo StaffThe NameSilo staff of writers worked together on this post. It was a combination of efforts from our passionate writers that produce content to educate and provide insights for all our readers.
More articleswritten by NameSilo
Jump to
Smiling person asking you to sign up for newsletter
Namesilo Blog
Crafted with Care by Professionals

Millions of customers rely on our domains and web hosting to get their ideas online. We know what we do and like to share them with you.

This newsletter may contain advertising, deals, or affiliate links. Subscribing to a newsletter indicates your consent to our Terms of Use and Privacy Policy. You may unsubscribe from the newsletters at any time.