Dealing with the max_execution_time exceeded error on your WordPress site? It's a common issue when a PHP script runs longer than the maximum time allowed by your server. This often happens during tasks like importing large files, backing up your site, or running resource-heavy plugins. Don’t worry, though! We’ve got a quick and easy guide to fix it.
How to fix the max_execution_time WordPress error (Quick Guide)
You can do this by modifying the php.ini or wp-config.php files, or by adjusting settings in your hosting control panel.
Example: If your server currently allows only 30 seconds, increasing this to 300 seconds (5 minutes) usually solves most timeout problems.
4 simple steps to fix the max_execution_time WordPress error:
- Increase PHP max_execution_time through your php.ini file.
- Or modify the wp-config.php file to increase the execution time.
- You may also use a plugin to increase the time limit without coding.
- Alternatively, contact your hosting provider if the error still appears.
It’s as easy as that! Let’s dive in and get this fixed.
What is the max_execution_time error in WordPress?
If your WordPress site runs into the max_execution_time exceeded error, it means a script took too long to execute. WordPress, by default, limits how long a PHP script can run. This error happens in WordPress quite often when sites have more plugins, tasks, users, or traffic.
Every WordPress site should avoid such errors because they can harm, for example, user experience or a WooCommerce business.
Once this time limit is exceeded, you’ll see this error. This is common with tasks like large imports, backups, or any process that requires a lot of resources.
How to confirm in WordPress max_execution_time issue?
To know whether max_execution_time is causing the issue, check your PHP error logs for messages like “maximum execution time exceeded.” If you have WooCommerce installed, go to its Settings → Status → Logs to see if there are any error notifications.
Ok, are you ready to fix the problem? Let’s jump into increasing the max_execution_time to prevent this error from slowing down your site.
Why does WordPress throw the max_execution_time error?
The max_execution_time error usually occurs when WordPress tries to process a large or complex task, and the server doesn’t have enough time to complete it. Here are a few common reasons:
- Large media files (images, videos) taking too long to upload or process.
- Heavy plugins or complex themes using up a lot of resources.
- Extended operations like importing/exporting products, especially in WooCommerce.
- Traffic spikes that use specific scripts
Time limit in WordPress
Your site may have the default execution time of 30 seconds. In that case, more scripts or processes can make time of 30 seconds exceeded.
For example, when you upload large media files and the error occurs again, you need to increase the maximum execution time limit.
Maximum execution time for WP plugins
You may also try deactivating plugins one by one or switching to a default theme (like Twenty Twenty-Five or Storefront) to check if a particular plugin or theme is causing the issue.
Now that you know why this happens, let’s move on to fixing the issue by increasing your max_execution_time.
How to increase the max_execution_time in WordPress?
Increasing the PHP max_execution_time is simple, and you can do it in several ways. Let’s walk through the two most common methods:
1. php.ini File Method
Add this line to your php.ini file:
max_execution_time = 300
Then, restart your server to apply changes.
This increases the time limit to 300 seconds (5 minutes), which is usually enough for most operations.
Where to Find the php.ini File:
The php.ini file is typically located in your server’s root directory or in the folder where PHP files are stored. You can also access it via cPanel under PHP Configuration.
If you can't find the file, you can add it to the main directory of the WordPress installation.
2. wp-config.php method
Add this line to your wp-config.php file before "That's all, stop editing!" line:
set_time_limit(300);
This is a WordPress-specific way to increase the execution time, and it’s effective if the previous methods don’t work. But, this can be blocked by shared hosting providers - in that case, contact your hosting technical support for assistance.
Where to Find wp-config.php:
You’ll find the wp-config.php file in your WordPress root directory. Access it via FTP or cPanel.
Can recommend it
Always back up your WordPress site before making any changes to these files.
Now that you’ve learned how to increase execution time, let’s see how plugins can also help resolve this issue.
Can plugins help fix the max_execution_time error?
Yes, they can! If you prefer a no-code solution, you can use plugins to increase the PHP execution time directly from your WordPress dashboard.
For example, you may install the MaxUploader WordPress plugin, which will automatically adjust your max execution time without needing to touch any code.
It's perfect for those who want to avoid manually editing server files. However, if the error persists, you might need to reach out to your hosting provider for further assistance.
How to fix the max_execution_time Error with your hosting provider?
If none of the above solutions work, your hosting provider may be able to help.
Some hosting providers apply strict max_execution_time limits to prevent server overload, especially on shared hosting environments.
But, they can increase the execution time limit on their side. Request that they increase the 30-second time limit or other server settings.
Increase the PHP time limit by hosting provider
Contact your hosting provider and ask them to increase the max_execution_time for your WordPress site.
Sometimes, your host may offer additional tools or resources to optimize performance and prevent time-related errors. You may describe the issues you encounter so they can understand what to fix.
Ok. Time limit set, what next?
How to prevent max_execution_time errors in the future?
To ensure this error doesn’t keep happening, here’s what you can do:
1. Optimize plugins and themes
- Disable unnecessary plugins that consume resources.
- Use lightweight themes that don’t overload the server.
- Have recent version of WordPress (or WooCommerce)
- Change the PHP version so that scripts run faster and need less time using memory of the server
2. Break up large tasks
If you’re running large imports or backups, break them into smaller tasks to avoid exceeding the time limit. For example, updating a lot of products can overload the server.
3. Upgrade your hosting
Consider upgrading to managed WordPress hosting or VPS for better performance and higher execution time limits compared to shared hosting.
4. Maximum execution time limit hack
You may also use caching plugins like W3 Total Cache or LiteSpeed Cache to optimize performance and reduce server load.
Optimizing your WordPress site will help prevent max_execution_time errors from happening again or so often.
Summary
Here’s a quick recap of what you can do to fix the max_execution_time WordPress error:
- Increase max_execution_time using .htaccess or wp-config.php.
- Optimize plugins and themes to reduce resource consumption.
- Use a plugin to increase execution time easily.
- Contact your hosting provider if the error persists.
- Optimize your site for better long-term performance.
By following these simple steps, your WordPress site will run smoothly without hitting the max_execution_time error.
You don't want to see in WordPress max_execution_time fatal error, do you?
Questions & Answers Section
1. What causes memory issues in WordPress?
Memory issues can arise from:
- Heavy plugins or poorly optimized themes.
- Large media files like images or videos consuming too much memory.
- Outdated plugins or WordPress versions using more resources than necessary.
- Shared hosting environments, where server resources are limited.
2. What happens if memory runs out?
When memory runs out, it can lead to:
- Slow page load times, negatively affecting user experience and SEO.
- Server crashes causing temporary downtime.
- Error messages like fatal errors or memory limit exceeded.
- Losing users.
3. How to maintain a fast WordPress site?
To maintain a fast site:
- Use caching plugins like W3 Total Cache or LiteSpeed Cache.
- Optimize images with tools like Smush or Converter for Media.
- Limit the number of plugins.
- Regularly clean your database.
4. How much memory does WordPress and WooCommerce need?
On average:
- WordPress requires 64 MB to 128 MB of memory.
- WooCommerce needs 128 MB to 256 MB, depending on the size of the store and product count.
Try to increase the max execution time to 300 and set memory to 512MB or 1GB if you observe traffic peaks or plan to run more memory-heavy tasks for your WordPress website.
You may also track current execution limit and memory usage with the Query Monitor plugin.