Table of Contents
How to Fix PHP Fatal Error: Maximum Execution Time of 30 Seconds Exceeded
While working on PHP projects, especially in local environments like XAMPP, you may encounter an error message such as:
Fatal error: Maximum execution time of 30 seconds exceeded...
This error occurs when a PHP script runs longer than the time limit defined in the server configuration. By default, PHP allows scripts to execute for only 30 seconds. If your script takes longer — due to large database queries, file uploads, API calls, or heavy processing — PHP automatically stops execution to prevent server overload.
Common Reasons for This Error
- Long-running database queries
- Large file uploads or data imports
- External API requests taking too long
- Infinite loops in code
- Low system resources (RAM/CPU) on your local machine
Fortunately, if you're working on a local server like XAMPP, you can easily increase the execution time limit by modifying the php.ini file.
Steps to Increase PHP Execution Time in XAMPP
- Open the php.ini file. You can find it inside the xampp/php/ folder.
- Open the file in Notepad or any code editor.
- Press Ctrl + F and search for max_execution_time.
- You will see something like: max_execution_time = 30.
- Change it to: max_execution_time = 120 (or higher if required).
- Save the file.
- Stop Apache from the XAMPP Control Panel.
- Restart Apache to apply the changes.
After restarting Apache, PHP scripts will be allowed to run for up to 120 seconds instead of 30 seconds. This helps resolve the fatal execution time error in most local development cases.
Alternative Temporary Fix (Inside PHP File)
If you do not want to edit the php.ini file, you can also increase the execution time within a specific PHP script using:
This sets the maximum execution time to 120 seconds for that particular script only.
Important Notes
- Increasing execution time is a temporary solution — always try to optimize your code.
- Check for infinite loops or unoptimized database queries.
- On live servers, you may need hosting provider access to modify php.ini settings.
Conclusion
The “Maximum execution time of 30 seconds exceeded” error is common in PHP development, especially during heavy operations. By adjusting the max_execution_time value in the php.ini file or using set_time_limit(), you can quickly resolve the issue in your local XAMPP environment.

