Increasing the WordPress memory limit is a common solution to resolve issues caused by insufficient PHP memory allocation. This adjustment can help prevent errors such as the “Allowed memory size exhausted” message, improve site stability, and allow resource-intensive plugins or themes to run smoothly. Before you start, it’s important to have access to your website’s files via FTP, cPanel, or a file manager, and a basic understanding of editing configuration files.
What You’ll Need
- Access to your WordPress root directory via FTP client or hosting control panel file manager
- Basic text editor (Notepad, VS Code, Sublime Text, etc.)
- Access to your hosting account’s control panel (optional, for php.ini or cPanel adjustments)
- WordPress administrator credentials (to verify changes and test site functionality)
Step-by-Step
- Check Your Current Memory Limit – Before making changes, verify your current memory limit. You can do this by installing a plugin like “WP Health” or “Site Health” and navigating to the server info section, or by creating a PHP info file. This helps you know your starting point.
- Edit the wp-config.php File – Connect to your site via FTP or file manager, locate the
wp-config.phpfile in your WordPress root directory. Open the file in a text editor and add the following line above the line that says “That’s all, stop editing! Happy blogging”:define('WP_MEMORY_LIMIT', '256M');
This increases the memory limit to 256 megabytes, which is sufficient for most sites. - Save and Upload the File – After adding the line, save the file and upload it back to your server if you’re using FTP. If using a file manager, just save the changes.
- Increase PHP Memory Limit in php.ini (If Possible) – Some hosts allow you to modify the
php.inifile. Locate or create aphp.inifile in your root directory or the folder where WordPress is installed, then add or modify this line:memory_limit = 256M
If you can’t find or accessphp.ini, your host might not allow this, so skip this step. - Adjust .htaccess File (Alternative Method) – If you cannot edit
php.ini, try adding this line to your.htaccessfile in the WordPress root directory:php_value memory_limit 256M
Be cautious with this method, as incorrect edits may cause server errors. - Contact Your Hosting Provider – If none of the above methods work, your hosting provider may have a hard limit on PHP memory. Contact their support and request an increase in memory allocation.
- Verify the Changes – Return to your WordPress admin or use a PHP info file to confirm the memory limit has increased. Also, test your site thoroughly to ensure no new errors occur.
Common Mistakes
- Editing the Wrong File – Modifying the wrong
wp-config.phpor editing files outside the root directory can cause the changes to have no effect. - Incorrect Syntax – Missing semicolons or incorrect quotes in configuration files can break your site or cause parse errors.
- Setting Memory Limit Too High – Setting an excessively high memory limit (e.g., 1024M) without server support can lead to server crashes or ignored settings.
- Not Backing Up Files – Changing core files without a backup risks losing data or site functionality if mistakes are made.
- Ignoring Hosting Restrictions – Some hosts do not allow increasing memory limits manually, so changes won’t take effect unless they update server settings.
Tips
- Start with 256M – This value suits most WordPress setups. Increase only if necessary after testing.
- Use Child Themes and Plugins Wisely – Sometimes memory issues arise from poorly coded plugins or themes. Audit and disable unnecessary ones.
- Use a Staging Site for Testing – Always test changes on a staging environment to avoid downtime on your live site.
- Monitor Memory Usage – Install monitoring plugins to track memory consumption over time and identify problematic processes.
- Keep WordPress Updated – Updates often include performance improvements that can reduce memory usage.
Troubleshooting
If your WordPress memory limit does not increase as expected, consider the following steps:
- Confirm File Edits Are Saved – Sometimes FTP clients fail to upload changed files properly. Re-upload and clear caches.
- Check for Server Overrides – Hosting providers might have server-level configurations that override your settings. Contact them to verify.
- Review Error Logs – Enable error logging in WordPress and check server logs for clues about memory-related errors.
- Test Alternative Methods – If editing
wp-config.phpdoesn’t work, tryphp.inior.htaccessmethods as described above. - Disable Conflicting Plugins – Some plugins may interfere with memory settings. Disable all plugins and re-enable one by one to find conflicts.
- Verify PHP Version Compatibility – Older PHP versions might handle memory settings differently. Upgrade PHP if necessary.
Frequently Asked Questions
- How do I know if my WordPress memory limit is too low?
- If you see errors like “Allowed memory size exhausted” or your site crashes during plugin/theme operations, your memory limit is likely insufficient.
- Can I increase memory limit beyond 256M?
- Yes, but it depends on your hosting environment. Higher limits like 512M or 1G may be allowed on VPS or dedicated servers but usually not on shared hosting.
- Is increasing memory limit a permanent fix for slow WordPress sites?
- Not always. While it can help with memory-related errors, slow performance might also be due to poor hosting, unoptimized code, or excessive plugins.
- Will increasing memory limit affect my hosting costs?
- Generally, no. However, if your site demands more resources consistently, your host may recommend upgrading your plan.
- What if I don’t have access to wp-config.php or php.ini?
- Contact your hosting provider’s support team. They can often increase the memory limit for you or guide you through alternative solutions.
- Can I increase memory limit via a plugin?
- Some plugins claim to increase memory limit by editing configuration files, but manual editing is more reliable and transparent.
Increasing the WordPress memory limit is a straightforward process, but it requires careful handling of configuration files and awareness of your hosting environment. By following the steps above and keeping common pitfalls in mind, you can enhance your site’s stability and performance effectively.
Related
- Plants That Live a Long Time: 10 Remarkably Durable Species
- Plants That Don’t Grow Big: Top Compact Varieties to Try
- Best Plants That Thrive in USDA Zone 7a Gardens