Skip to content

How to fix WordPress memory out of memory error by increasing PHP memory limit?

The out of memory error is a common problem encountered by WordPress users. It appears when your WordPress script tries to use more memory than allowed by your server settings. Here are some solutions to help increase your PHP memory limit to avoid this error.

1. Increase PHP memory limit via wp-config.php file

The simplest solution is to increase the PHP memory limit directly in the WordPress configuration file – wp-config.php. This file is located in the root directory of your WordPress installation. Open this file with any text editor and add the following line of code:

define('WP_MEMORY_LIMIT', '256M');

This line of code increases the memory limit to 256 MB, which is usually enough for most websites. You can set a higher value if your site is more demanding.

2. Change PHP memory limit using .htaccess file

If changing wp-config.php did not bring the desired effect, you can try increasing the PHP memory limit using the .htaccess file. It is also located in the main WordPress directory. Open this file in a text editor and add the following lines of code:

php_value memory_limit 256M

As before, you can adjust the 256M value to suit your site's needs.

3. Increase the memory limit using the php.ini file

Jeżeli powyższe metody nie działają, problem może leżeć w ustawieniach PHP na serwerze. W takim przypadku musisz zwiększyć limit pamięci za pomocą pliku php.ini. Otwórz ten plik w edytorze tekstu i znajdź linię zawierającą „memory_limit”. Zmień wartość na 256M lub wyższą.

4. Use a WordPress plugin to increase your memory limit

Jeżeli nie jesteś pewien swoich umiejętności w edycji plików konfiguracyjnych, możesz zastosować wtyczkę do zwiększenia limitu pamięci. Wtyczka „WP Memory Limit” to jedno z takich narzędzi, które ułatwiają ten proces.

5. Contact your hosting provider

If none of the above methods work, most likely your hosting cannot be configured to increase the PHP memory limit. In this case, contact your hosting provider and ask them to increase the PHP memory limit.

Remember that increasing the PHP memory limit is only a temporary solution. If your website is constantly sucking up a lot of memory, you should identify and fix the problem. This may require optimizing your website, updating your plugins, or changing your theme.

Check out the offer of 1500+ Premium WordPress plugins and themes!