Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Troubleshooting · Guide

How to Increase max_execution_time in WordPress

Short answer

Raise max_execution_time to 300 seconds in php.ini, or add set_time_limit(300) to wp-config.php before the stop-editing line. Use php_value max_execution_time 300 in .htaccess only on Apache with mod_php. Then check Tools > Site Health > Info > Server and repeat the task.

Key takeaways

  • PHP sets max_execution_time to 30 seconds by default, and 0 on the command line.
  • 300 seconds is a good start for imports and backups, and 600 seconds is for long migrations only.
  • php.ini is the most direct method; wp-config.php sets the limit for WordPress requests only.
  • A php_value line in .htaccess causes a 500 error on hosts that run PHP-FPM.
  • Check the new value in Tools > Site Health > Info > Server before you repeat the task.

What is max_execution_time in WordPress?

max_execution_time is the PHP limit, in seconds, for how long one PHP script may run before PHP stops it.

PHP sets the default to 30 seconds. The PHP manual states that the default setting is 30, and that the command-line default is 0, which means no limit there.

WordPress runs on PHP, so the limit applies to imports, backups, updates, and other long admin tasks. A normal page load should finish well inside 30 seconds. A large import or a backup may not.

When a script passes the limit, PHP stops it and WordPress shows a fatal error. The error text reads “Maximum execution time of 30 seconds exceeded” or a similar line with your own limit in place of 30.

What do you need before you start?

You need a backup, your current limit value, and the name of the PHP setup your host uses.

Back up files and the database before you edit any server file. A wrong line in .htaccess or php.ini can stop the whole site, so a backup you can restore is the first step.

Find your current value in Tools > Site Health > Info, then open the Server section. It lists the PHP time limit, PHP version, and memory limit. Write the current number down before you change it.

Also check which PHP setup your host uses. The Server section shows the PHP SAPI value. If it says fpm-fcgi, .htaccess php_value lines will not work, and may cause a 500 error instead.

  • A current backup of files and the database
  • Your current max_execution_time value from Site Health
  • File access through your host panel, SFTP, or SSH
  • 15 to 30 minutes, plus time to repeat the failing task

How do you increase max_execution_time in php.ini?

Set max_execution_time = 300 in the php.ini file your site reads, then check Site Health to confirm the new value.

This is the most direct method when your host gives you access to php.ini. The PHP manual lists the core directives, and the PHP runtime page gives the default of 30 seconds for this setting.

Follow these steps:

  1. Open your host control panel and find the PHP settings screen. In cPanel it is called MultiPHP INI Editor or Select PHP Version.
  2. Select your domain and find max_execution_time.
  3. Change the value to 300.
  4. Save the change.
  5. Go to Tools > Site Health > Info > Server and check that the time limit now reads 300.

If your host gives no PHP settings screen, edit the file by hand. Find php.ini in your site root or ask your host for its path, then add or change this line:

max_execution_time = 300

Save the file. Some hosts need a PHP restart before the change applies. If Site Health still shows the old value after a few minutes, ask your host to restart PHP or to apply the change for you.

How do you increase it in wp-config.php?

Add a set_time_limit(300); line to wp-config.php before the stop-editing line, so the change applies to WordPress requests only.

This method does not change the server-wide PHP setting. It sets the limit for the WordPress script that is running, which is often enough for an import or a backup that runs inside WordPress.

Follow these steps:

  1. Open wp-config.php in the root folder of your site.
  2. Find the line that reads /* That's all, stop editing! Happy publishing. */.
  3. Add this line just above it:
set_time_limit(300);
  1. Save the file and repeat the task that timed out.

The PHP manual notes that set_time_limit() restarts the timeout counter from zero when it is called. Setting it to 0 removes the limit for that request, but that step is not wise on a live site, because a stuck script can then run without end.

If your host blocks set_time_limit(), this method will have no effect. Check Site Health after the change. If the value is unchanged, use the php.ini method or ask your host instead.

How do you increase it in .htaccess?

Add php_value max_execution_time 300 to .htaccess, but use this method only on Apache with mod_php or a matching LiteSpeed setup.

This method is the riskiest of the three. On many modern hosts, PHP runs as PHP-FPM, and a php_value line in .htaccess causes a 500 error. Check your PHP SAPI value in Site Health first.

Follow these steps:

  1. Open your host file manager and show hidden files, so .htaccess is visible.
  2. Download a copy of .htaccess before you edit it.
  3. Open .htaccess and add this line outside the WordPress rewrite block:
php_value max_execution_time 300
  1. Save the file and load your site.

If the site shows a 500 error at once, remove the line you added and restore your backup copy. That result means your host does not support PHP settings in .htaccess. Use the php.ini method instead.

The value 300 means 300 seconds, which is 5 minutes. That is enough for most imports and backups. A larger value, such as 600, gives 10 minutes, but it also lets a slow or stuck script hold a worker for longer.

Which value should you choose?

Start at 300 seconds for imports and backups, and use a lower value for normal page loads.

The table below gives a starting point for common tasks. Pick the smallest value that lets the task finish.

TaskStart valueWhy
Normal page load30 secondsPHP default, and a page should finish fast
Large plugin or theme import300 secondsGives a big file time to process
Full site backup300 secondsCovers files and database in one run
Large media import300 secondsCovers many files in one batch
Migration with many posts600 secondsCovers a long batch, only when needed
Any task that still failsAsk the hostA higher limit may hide a slow plugin

PHP sets the default to 30 seconds, as the PHP manual states. A value of 300 is 10 times that default, which is a large jump. Do not set the limit to 0 on a live site, because that removes the limit and lets a faulty script run without end.

If a task still fails at 600 seconds, the limit is probably not the real cause. A slow plugin, a large database, or a weak hosting plan is more likely. Raising the limit further hides that fault instead of fixing it.

How do you check the new limit worked?

Repeat the task that timed out, then confirm the value in Site Health and watch for the same error.

First, open Tools > Site Health > Info > Server and read the PHP time limit. It should show the value you set, such as 300. If it shows the old value, your change did not apply, and you need to check which php.ini file your site reads.

Second, repeat the exact task that failed. Use the same file, the same import, or the same backup.

If it now finishes, the new limit helped. If it fails at the same point, note the time it ran before it stopped.

Third, check the error log. A fatal error that names a plugin file points to that plugin, not to the limit. The guide on what causes the time limit error covers the messages that point to a slow plugin or a large database.

If the task finishes but takes close to the full limit, split it into smaller parts. Import in batches of 500 posts instead of 5,000, or back up files and the database in two runs.

What if the host will not let you change it?

Ask the host to raise the limit, or move the long task to a staging copy or to WP-CLI.

Some shared hosts lock PHP settings at the server level. In that case, no edit to php.ini, .htaccess, or wp-config.php will change the value. Site Health will keep showing the old number after every change you make.

Ask support with a clear request: the setting name, the value you want, and the task that needs it. For example, ask for max_execution_time set to 300 seconds for a site migration. A host can often raise it for one site, or raise it for a short time.

If the host will not raise it, split the task. Import a large file in smaller parts, use a migration plugin that works in batches, or run the import with WP-CLI, which uses a default of 0 for max_execution_time, as the PHP manual states for the command line.

The guide on the 504 gateway timeout covers a related fault, where a server or proxy stops a long request before PHP finishes it.

What mistakes should you avoid?

Do not set the limit to zero, do not edit the wrong php.ini file, and do not use .htaccess on PHP-FPM.

The most common mistake is adding a php_value line to .htaccess on a host that runs PHP-FPM. That step causes a 500 error on every page, and the site stays down until you remove the line. Check the PHP SAPI value first.

A second mistake is editing the command-line php.ini file instead of the web php.ini file. The two files are separate, and a change to the command-line file will not affect web requests. Ask your host for the path to the web php.ini file if you are not sure.

A third mistake is raising the limit to hide a slow plugin or a large database. A backup that needs 600 seconds today may need 900 seconds next month, while the real fault stays hidden. Fix the slow task first, then set a limit that fits it.

Other mistakes to avoid:

  • Editing .htaccess with no backup copy saved first
  • Setting max_execution_time to 0 on a live site
  • Changing the limit and the plugin at the same time, which hides the cause
  • Forgetting to check Site Health after the change, so you never know if it applied

Check your PHP version while you are here. WordPress.org recommends PHP 8.3 or greater, with MySQL 8.4 or MariaDB 10.11 or greater.

A newer PHP version runs faster than an old one, so a task that timed out on PHP 7.4 may finish inside 30 seconds on PHP 8.3. The guide on checking your PHP version shows where to find the version your site runs.

Frequently asked questions

What is the default max_execution_time in PHP?

PHP sets the default to 30 seconds, and the command-line default is 0. A normal page should finish well inside 30 seconds, while a large import or backup may need 300 seconds, which is 5 minutes.

Does the .htaccess method work on every host?

No, not on most modern hosts. If PHP runs as PHP-FPM, a php_value line in .htaccess causes a 500 error. Check the PHP SAPI value in Site Health first, and use php.ini or wp-config.php when it says fpm-fcgi.

Is it safe to set max_execution_time to 0?

Setting it to 0 removes the limit for that request, so a stuck script can run without end. Do not use 0 on a live site. Use 300 seconds for imports and backups, and ask your host if a task still needs more.

How do I check my current max_execution_time?

Open Tools > Site Health > Info and expand the Server section. It lists the PHP time limit, PHP version, and memory limit. If it still shows the old value, your change did not apply to the php.ini file your site reads.

What can I do if my host will not raise the limit?

Split the task into smaller parts, use a plugin that works in batches, or run it with WP-CLI, which uses a default of 0 for max_execution_time. Ask your host to raise the limit for the migration if none of those steps work.

Sources

  1. Runtime Configuration PHP.net
  2. Description of core php.ini directives PHP.net
  3. Editing wp-config.php WordPress Developer Resources
  4. Requirements WordPress.org
  5. Troubleshooting your site: Plugin and theme conflicts Learn WordPress

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.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test