Once in a while, you will run into what can be a common problem with WordPress. You make some changes to the site, add a new plugin or do something else, and suddenly, all you see a blank white screen instead of your website. The browser screen is white, except for an error that reads something like this:
Fatal error: Out of memory (allocated 71565312) (tried to allocate 16 bytes) in /home/name/public_html/wp-includes/wp-db.php on line 1545
The key phrase in that error is “Out of memory.” That means your webhost or your web server ran out of memory when WordPress was trying to do something that required a lot of memory, that last thing you did, like adding a plugin.
The fix is simple: you need to give WordPress more memory. And the way to fix the error and the memory problem is usually fairly easy.
But before we fix it, realize that most web hosting providers – but not all – will allow you to bump WordPress’s memory allocation a little higher. Many hosts set their RAM allocations a little low to allow all the sites on the server to run and prevent some sites from hogging all the RAM. But some hosts, like free hosts (and even some popular paid hosts) limit RAM to the degree that don’t have enough for a handful of plugins and won’t allow you any more. And even after trying the changes below, you will continue to get these out of memory errors using common plugins or trying to handle a lot of traffic. At that point, the only solution is to change hosts.
But that’s worst case. Let’s try the memory bump fixes below and see if they work in your case. And 98% of the time, one of these fixes will work.
The easiest memory bump is to add a line to your wp-config.php file. This is the WordPress configuration file you edited when you originally installed WordPress. (If you don’t know where it is, see wp-config.php at the WordPress Codex.) If you did a “one click” WordPress install at your web host, you wouldn’t have had to edit the file when you first installed WordPress, but the file is easy to edit anyway.
First, you need an FTP client like Filezilla, which is made in versions for both Mac and Windows. You need to download and install Filezilla if you don’t already have it. (For help with FTP clients, see FTP Clients – WordPress Codex ). You will need to enter FTP details for your account at your web host. You will need to get those details from the emails you got from your webhost, or go into the Cpanel at your webhost and get them. Worst case is that you will need to set up an FTP account for yourself in Cpanel.
Or, you may be able to not have to download and use Filezilla if you can use a file editor in the Cpanel of your webhost. Many hosts have built in file editors you can use for a job like this without having to set up FTP and an FTP account at the webhost. Check with your host or look around in Cpanel for both FTP settings or a file editor.
Now, using FTP (or a file editor in Cpanel), open the wp-config.php file. It will be in the same directory as all the other WordPress files and folders, like wp-admin, wp-content, index.php, etc.
You will be adding a line to wp-config.php in order to increase memory for WordPress as a whole. The line is shown below. It “defines” more memory for WordPress as it runs, and it gives WordPress 64 megs of RAM.
Add the line below a few lines of white space after the opening
<?php declaration, and not before it. And be careful not to add it anywhere in the comments area bracketed with the
/** symbols. (It’s a good idea to backup the file or make a copy of it before you edit. Download a copy to your desktop.)
This is the line to add:
Save the file and close it. Check your site. If you get errors after you add that, like “Headers already sent” or some sort of parse error, you made a mistake in your editing, so go back and edit the file again.
The file should look like this:
If that memory bump doesn’t work and you still get out of memory errors, look for a php.ini file in your hosting account. This is a more complex way to raise memory, but it will work on some hosts. If you don’t see a php.ini file, ask your web host if you can add one because you need to raise the memory allocation for WordPress. They will tell you if their servers allow php.ini files. You may be able to add a blank file called php.ini and add this one line to it:
memory_limit = 64M;
As I mentioned before, some hosts won’t allow you to raise the memory allocation for your account. If you get a 500 server error, or see no change, you may be out of luck. Delete the php.ini file. And then ask your webhost.
And if you’re on a VPS or a dedicated server, it’s a bit more complex, as there are more steps to take to best adjust the memory for both WordPress and all php processes.