The "fatal error or timeout occurred" message in cPanel or a PHP application usually indicates that the PHP script exceeded one or more resource limits, such as execution time, memory usage, or file upload size. Here's how to increase PHP limits step by step to resolve the issue.
Identify the PHP Configuration File (php.ini)
Before changing PHP limits, you need to know which PHP configuration file is being used.
Find the Active php.ini
- Create a new PHP script called
phpinfo.phpin your web directory:<?php phpinfo(); ?> - Access the script in your browser:
http://yourwebsite.com/phpinfo.php - Look for the Loaded Configuration File section. It will show the path to the active php.ini file (e.g.,
/etc/php/8.0/apache2/php.ini).
Edit the php.ini File
The most common solution is to increase the relevant limits in php.ini.
Steps to Increase PHP Limits
- Open the php.ini file:
sudo nano /etc/php/8.0/apache2/php.ini - Locate and adjust the following settings:
; Maximum execution time of each script, in seconds max_execution_time = 300 ; Maximum amount of memory a script may consume memory_limit = 512M ; Maximum allowed size for uploaded files upload_max_filesize = 100M ; Maximum size of POST data that PHP will accept post_max_size = 100M ; Maximum input time for parsing POST/GET data (in seconds) max_input_time = 300 - Save the changes and exit the editor.
- Restart your web server to apply the changes:
- For Apache:
sudo systemctl restart apache2 - For NGINX:
sudo systemctl restart php8.0-fpm
- For Apache:
Override PHP Settings with .htaccess
If you cannot edit the php.ini file (e.g., on shared hosting), you can override these settings using an .htaccess file.
Add Settings to .htaccess
- Open or create the
.htaccessfile in the root directory of your application. - Add the following lines:
# Increase PHP execution time and memory limits php_value max_execution_time 300 php_value memory_limit 512M php_value upload_max_filesize 100M php_value post_max_size 100M php_value max_input_time 300 - Save the file and reload your website.
Override PHP Settings with ini_set in Code
If you cannot modify php.ini or .htaccess, you can temporarily increase PHP limits within the script.
Add ini_set Calls to Your PHP Code
Insert the following lines at the beginning of the affected PHP script:
<?php
// Increase PHP limits
ini_set('max_execution_time', 300); // 5 minutes
ini_set('memory_limit', '512M'); // 512 MB
ini_set('upload_max_filesize', '100M');
ini_set('post_max_size', '100M');
ini_set('max_input_time', 300);
?>
Verify Changes
After modifying the PHP limits, confirm that the new settings are applied.
Recheck with phpinfo()
- Reload your
phpinfo.phpscript in your browser. - Verify that the updated values appear for:
max_execution_timememory_limitupload_max_filesizepost_max_size
Debugging Timeouts or Fatal Errors
If the issue persists, collect more information about the error.
Enable PHP Error Reporting
- Add the following code to your script to display detailed error messages:
<?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> - Re-run the script and note the exact error message.
Example Scenarios
Here are two common scenarios with solutions:
Scenario 1: File Uploads Fail with Timeout
Error Message:
Maximum execution time of 30 seconds exceeded
Solution: Increase the max_execution_time, memory_limit, and upload_max_filesize in php.ini or .htaccess:
max_execution_time = 300
memory_limit = 512M
upload_max_filesize = 100M
post_max_size = 100M
Scenario 2: Out of Memory Error
Error Message:
Fatal error: Allowed memory size of 128M exhausted
Solution: Increase the memory_limit in php.ini or .htaccess:
memory_limit = 512M
Final Steps
- Restart Services: Ensure you restart the web server after making changes to php.ini.
- Test Your Script: Run the application or process again to confirm the issue is resolved.
- Monitor Logs: Check logs for additional issues:
- Apache:
tail -f /var/log/apache2/error.log - PHP:
tail -f /var/log/php_errors.log
- Apache:
Summary
To resolve "A Fatal Error or Timeout Occurred While Processing This Directive", increase the relevant PHP limits using one of these methods:
- Modify the php.ini file.
- Use an .htaccess file for overrides.
- Add ini_set calls in your PHP script.
- Verify the changes using phpinfo().
By following these steps, the timeout or fatal error should be resolved.


