Cloudflare 524 means the connection between Cloudflare and your origin server timed out — your server took too long to respond. This guide covers every possible cause.
Understanding Cloudflare 524
Browser → Cloudflare → Your Server
# 524 = Cloudflare connected to your server
# but server didn't respond within 100 seconds
Step 1 — Identify the Slow Request
# Check Nginx access log for slow requests
awk '$NF > 5' /var/log/nginx/access.log | tail -20
# Last field is request time in seconds
# Enable request timing in Nginx
log_format timed '$remote_addr - [$time_local] "$request" $status $upstream_response_time';
Step 2 — Fix PHP Script Timeout
# Increase PHP max execution time
sudo nano /etc/php/8.2/fpm/php.ini
max_execution_time = 300
max_input_time = 300
sudo systemctl restart php8.2-fpm
Step 3 — Fix Nginx Timeout
# In Nginx site config
fastcgi_read_timeout 300;
fastcgi_send_timeout 300;
proxy_read_timeout 300;
proxy_connect_timeout 300;
Step 4 — Fix Long Database Queries
# Find queries taking over 5 seconds
SHOW PROCESSLIST;
-- Look for: Time > 5 and State = 'executing'
-- Kill long running query
KILL QUERY process_id;
-- Enable slow query log to find the culprit
SET GLOBAL slow_query_log = 1;
SET GLOBAL long_query_time = 5;
Step 5 — Fix WooCommerce/WordPress Timeouts
# Disable heartbeat during checkout
add_action('init', function() {
if(is_checkout()) {
wp_deregister_script('heartbeat');
}
});
# Increase WooCommerce order processing timeout
define('WC_HPOS_MIGRATION_BATCH_SIZE', 10);
Step 6 — Check Server Resources
# Is server overloaded?
top -bn1 | head -20
free -h
df -h
# Is MySQL slow?
mysqladmin -u root -p processlist
Conclusion
524 errors need server-side performance fixes. Our team diagnoses and resolves Cloudflare timeout issues and server performance problems.
Comments