Troubleshooting · Explainer
What Causes "Maximum Execution Time Exceeded" in WordPress?
Short answer
The error means a PHP script ran longer than the max_execution_time limit, so PHP stopped it with a fatal error. The usual causes are a slow import or backup, a heavy plugin or theme task, a slow database query, a low limit set by the host, or a script stuck in a loop.
Key takeaways
- The default PHP time limit is 30 seconds, and the number in the error message is the limit your host is using.
- The limit counts script time only, so time spent on database queries and system calls is not counted on most systems.
- Long imports, backups, and migrations are the jobs that hit the limit most often, because one request must finish the whole job.
- A timeout on every load of one page, naming the same file, points at a stuck loop or slow code rather than a low limit.
- Setting the limit to zero removes it entirely, which lets a broken script run until the server stops it another way.
What does “Maximum Execution Time Exceeded” mean?
The error means a PHP script ran longer than the time limit the server allows, so PHP stopped it.
The full message reads “Maximum execution time of 30 seconds exceeded” or the same words with a different number, such as 60. WordPress.org's Common WordPress Errors page says the message means a process is taking too long to complete and is timing out.
The number in the message is the limit in seconds, not the size of the job. The WordPress PHP compatibility guide explains which PHP versions a site can run, since limits and defaults can differ between hosts.
A script that needs 40 seconds of work fails on a 30 second limit and passes on a 60 second limit, even though nothing about the job changed.
What sets the time limit on a WordPress site?
The limit comes from the max_execution_time setting in PHP, not from WordPress itself.
PHP's manual for set_time_limit says the default timeout is 30 seconds, and that calling set_time_limit restarts the timeout counter from zero. A call of set_time_limit(20) made 25 seconds into a script gives a total of 45 seconds before the script times out.
The same PHP manual page says the limit and the set_time_limit function only affect the time the script itself runs. Time spent on system calls, stream operations, and database queries is not counted when PHP works out how long the script has run, except on Windows, where the measured time is real time.
Hosts can set their own limit above or below the 30 second default. Some shared hosts cap it at 30 seconds and do not allow a higher value, while managed hosts often allow 60, 120, or 300 seconds. The value shown in the error message tells you which limit your host is using.
What jobs most often hit the limit?
Long imports, backups, and bulk updates are the jobs that hit the limit most often.
A large media import, a full site backup, a migration, or a bulk image task runs one PHP request that must finish before the limit. If the job has thousands of items, the request can run past 30 seconds on a slow or shared server, even when the code is sound.
WordPress.org's Common WordPress Errors page lists three ways to raise the limit: a line in .htaccess, a line in php.ini, or asking the host. The php.ini line it shows is max_execution_time = 60, and the .htaccess line is php_value max_execution_time 60.
A plugin update that rebuilds data, a search index rebuild, or a WooCommerce order export can hit the same wall. The job is not broken; it simply needs more seconds than one web request is allowed. Full fix steps are in the guide to fix “Maximum Execution Time Exceeded”.
How can a slow plugin or theme cause the timeout?
A slow plugin or theme can cause the timeout by making one page load do far more work than it should.
A plugin that runs a heavy query on every page, calls a slow outside service, or loops through thousands of posts can push a normal request past the limit. The timeout then appears on ordinary pages, not only during imports or backups.
The clue is where the error appears. If it shows on one page or after one plugin was turned on, that plugin or theme is the likely cause. If it shows only during a backup or import, the job itself is the likely cause.
Developer.WordPress.org's Debugging in WordPress page shows how to write errors to wp-content/debug.log by setting WP_DEBUG and WP_DEBUG_LOG to true in wp-config.php.
The log names the file and line where the script stopped, which often points at the plugin doing the slow work. The guide to fix plugin conflicts covers how to narrow it down by turning plugins off one at a time.
How can a slow database query cause the timeout?
A slow database query can cause the timeout when a page waits on the database while PHP keeps counting.
PHP's manual for set_time_limit says time spent on database queries is not counted toward the limit on most systems. A slow query still matters, because the script around it keeps running and the page as a whole takes longer to finish.
A query that scans a large posts or options table without an index is a common cause. The guide on how to reduce autoloaded options explains what to look for in that table.
The autoloaded options table is one place this shows up: options marked for autoload load on every page, so a bloated table slows every request.
The debug log helps here too, since it shows the file and line where PHP stopped. If the stopped line sits inside a plugin's query or a theme function, that code is where the time went. A host-side slow query log, when the host provides one, shows the exact query and how long it took.
How can a stuck loop cause the timeout?
A stuck loop can cause the timeout by running the same code again and again until PHP stops it.
A loop with a condition that never turns false, or a recursive function that never reaches its end, burns through the whole time limit on one request. The page then fails with the same error every time it loads, which sets it apart from a job that is simply large.
The error message often names the file and line where PHP stopped, and that line sits inside the looping code. A loop that fails only sometimes, such as one that depends on a post count or a feed that changes, can look like an import problem until the log shows the same file each time.
A timeout that appears on every load of one page, with the same file named, points at code rather than at the limit. Raising the limit only delays the same failure.
The code needs fixing, or the plugin or theme that holds it needs to be turned off. Make WordPress Core's Fatal Error Recovery Mode in 5.2 note explains that WordPress catches fatal errors, emails the admin a recovery link, and pauses the failing plugin or theme for that browser.
How do you tell a low limit from a slow job?
You tell them apart by timing the job and by checking what the limit is set to.
First, find the limit. The error message states it directly: 30 seconds means the host limit is 30, and 60 means it is 60. PHP's manual lists core php.ini directives, and the max_execution_time entry is where the value lives in the server setup.
| Sign | Likely cause | Next check |
|---|---|---|
| Error only during imports, backups, or migrations | Job is too large for one request | Split the job or raise the limit |
| Error on one page after a plugin change | Slow plugin or theme code | Turn the plugin off and retest |
| Error on every load of one page, same file named | Stuck loop or broken code | Read the debug log for the file and line |
| Error at busy times across many pages | Slow server or slow database | Ask the host about load and slow queries |
Second, check how long the job should take. The guide to fix high CPU usage covers server-side slowness that makes normal jobs run long.
A small import that fails at 30 seconds points at a slow server or slow code, while a 50,000 row import that fails at 30 seconds points at a limit that is too low for the job.
What mistakes should you avoid?
Do not raise the limit to a huge number and leave it there.
A very high limit lets a stuck loop or a heavy plugin hold a PHP worker for minutes, which can slow the whole site for other visitors. Raise the limit only as far as the job needs, and only for the job that needs it, then set it back.
Do not set set_time_limit(0) on a live site. PHP's manual for set_time_limit says a value of zero means no time limit is imposed. That removes the safety net entirely, so a broken script can run until the server stops it another way.
Do not edit php.ini on shared hosting without checking whether the host allows it. Many shared hosts ignore php.ini changes or cap the value, so an edit that looks right may change nothing. Ask the host what the limit is and whether it can be raised before editing server files.
Frequently asked questions
Will raising max_execution_time to 300 seconds fix the error?
It depends on the job. A large import or backup that needs 45 seconds will pass on a 60 second limit and fail on a 30 second limit. A stuck loop will fail at any limit, because it never finishes. Raise the limit only when the job is sound and simply needs more time, and fix the code when the same page fails at every limit.
Why does a backup fail but a small import work on the same site?
Yes, on most hosts the limit applies to each web request. A backup plugin that splits its work into many short requests can finish a large job without hitting the limit, while a plugin that runs the whole job in one request cannot. Splitting the work is often a better fix than raising the limit, because it keeps each request short.
Can WordPress raise the time limit by itself?
WordPress sets no time limit of its own. The limit comes from PHP and the host, so WordPress cannot raise it by itself. A plugin can call set_time_limit during its own work, but the host can block that call or cap the value. When the host caps the limit, only the host can raise it.
Does a slow database query count toward the time limit?
No. The limit counts script time, and PHP's manual says time spent on system calls, stream operations, and database queries is not counted on most systems. A page can still time out when a slow query makes the script around it run long, but the query time itself is not what PHP counts. Check the debug log to see where the script actually stopped.
How do I find which file caused the timeout?
Open wp-config.php and add the debug lines from the WordPress debugging guide, then load the broken page once and open wp-content/debug.log. Look for the fatal error line naming the file and the line number. That file is usually the plugin, theme, or import script that was running when PHP stopped it.
Sources
- Common WordPress Errors WordPress.org
- set_time_limit PHP Manual
- Description of core php.ini directives PHP Manual
- Debugging in WordPress WordPress Developer Resources
- Fatal Error Recovery Mode in 5.2 Make WordPress Core
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
