Hostxpeed
Login Get Started →
Troubleshooting

Fix PHP "Maximum Execution Time Exceeded"

4 min read
28 views
Jun 10, 2026

Understanding the Error

Fatal error: Maximum execution time of 30 seconds exceeded

Fix 1: Increase max_execution_time

In php.ini:

max_execution_time = 300
max_input_time = 300

Restart PHP-FPM:

sudo systemctl restart php*-fpm

Fix 2: In Script (Temporary)

set_time_limit(300);  // 5 minutes
set_time_limit(0);     // Unlimited (use carefully)

Fix 3: WordPress wp-config.php

set_time_limit(300);

Fix 4: .htaccess for Apache

php_value max_execution_time 300

Fix 5: Optimize Slow Script

Don't just increase timeout - optimize the code:

  • Add database indexes
  • Process in chunks/batches
  • Use background jobs for heavy tasks

Check PHP-FPM Request Timeout

# /etc/php/*/fpm/pool.d/www.conf
request_terminate_timeout = 300

Nginx Timeout Settings

fastcgi_read_timeout 300s;
proxy_read_timeout 300s;

Was this article helpful?