Documentation » Troubleshooting
PHP Fatal error: Allowed memory size exhausted
If you see an error like PHP Fatal error: Allowed memory size of xxxxxxxxx bytes exhausted, PHP has run out of the memory it’s allowed to use.
Exhaustion of the PHP memory limit is a common issue in WordPress, and it often requires adjusting the memory limit to resolve it. Here are three ways to fix it.
Method 1: Edit wp-config.php #
- Access your WordPress files: Use an FTP client or the file manager provided by your hosting provider to access your website’s files.
- Locate wp-config.php: This file is in the root directory of your WordPress installation.
- Edit wp-config.php: Add the following line just before the line that says
/* That's all, stop editing! Happy blogging. */
define('WP_MEMORY_LIMIT', '256M');
This line sets the memory limit to 256MB. You can adjust this value according to your requirements (e.g., 512M, 1024M).
- Save the changes: Upload the modified wp-config.php file back to your server.
- Check if the issue is resolved: Visit your site and try accessing the page that was causing the error. If the error persists, try the next method.
Method 2: Edit php.ini #
- Locate php.ini: Some hosting providers allow access to a php.ini file. If you can find it in your hosting control panel or via FTP in the root folder, proceed.
- Edit php.ini: Find the line that specifies
memory_limitand increase its value. If it’s not present, add the following line:
memory_limit = 256M
Again, adjust the value as needed.
- Save the changes: Save the modified php.ini file.
- Restart your web server: In some cases, changes to php.ini require a server restart to take effect. Check your hosting documentation or control panel to restart the server.
- Check your site: Verify the error has been resolved by accessing the page that previously triggered the memory error.
Method 3: Contact hosting support #
If you don’t have access to these files, or modifying them doesn’t resolve the issue, contact your hosting provider’s support team. They can increase the PHP memory limit or identify any server-related issues causing the error.
Note: Keep backups before making any changes to your site’s files, especially if you’re not familiar with the process.