
How to Increase PHP Memory for WordPress
- Feb 9
- 10 min read
If your WordPress site is showing a "Fatal error: Allowed memory size exhausted" message, it means your PHP memory limit is too low. This can cause your site to malfunction or crash when running resource-heavy tasks like backups, image uploads, or using plugins like WooCommerce or Elementor. Increasing the PHP memory limit ensures smoother performance and prevents these errors.
Here’s how you can increase your PHP memory limit:
Check Current PHP Memory Limit: Use WordPress Site Health (Tools > Site Health > Info) or create a file to see your current memory settings.
Edit Configuration Files:
Add to your file.
For Apache servers, modify with .
Adjust by setting .
Use Hosting Control Panel: Many hosting providers offer tools to adjust PHP settings directly.
Verify Changes: Recheck memory limits in Site Health and test your site's functionality.
If these methods don’t work, your hosting provider may have a server-level cap. Contact them for support. For hassle-free management, platforms like WPWorld offer unlimited PHP memory, eliminating the need for manual adjustments.
How to Increase PHP memory Size in WordPress
Step 1: Check Your Current PHP Memory Limit
Before making any changes, it’s important to know your current PHP memory limit. This acts as your starting point and helps you identify any restrictions set by your hosting provider that might block you from increasing the limit. WordPress offers two easy ways to check this information, or you can use performance monitoring tools for deeper insights.
Check via WordPress Dashboard
WordPress includes a Site Health tool (introduced in WordPress 5.2) that simplifies this process. To access it, go to Tools > Site Health in your WordPress admin sidebar and click the Info tab.
Here’s what to look for:
Under the Server section, you’ll find the Server PHP Memory Limit, which indicates the maximum memory allowed by your hosting server for any PHP script. This is the hard limit set by your host.
In the WordPress Constants section, you’ll see both (for the front-end) and (for the admin area). These values show what WordPress is using within the constraints of the server’s limit. Keep in mind, WordPress cannot exceed the memory limit set by the server. For instance, if the server allows 128MB, increasing WordPress to 256MB won’t work.
Limit Type | Location in Site Health | What It Controls |
Server PHP Memory Limit | Info > Server | Maximum memory allowed by the hosting server |
WP_MEMORY_LIMIT | Info > WordPress Constants | Memory limit for the front-end |
WP_MAX_MEMORY_LIMIT | Info > WordPress Constants | Memory limit for the WordPress admin area |
Check Using a phpinfo() File
Another method involves creating a phpinfo() file, which provides a complete overview of your server’s PHP configuration, including the memory limit.
Here’s how:
Create a new text file with the following content:
Save the file as .
Upload it to your website’s root directory (usually called ).
Visit in your browser. Use the search function (Ctrl+F for Windows or Cmd+F for Mac) to locate "memory_limit" and check its value.
"phpinfo() is a PHP function or a snippet of code that takes in one or more parameters and returns a value. Running phpinfo() will display information regarding your site's PHP configuration." - Matteo Duò, Head of Content, Kinsta
Important Note: After checking your settings, delete the file immediately to avoid exposing sensitive server information. If you need to keep it temporarily, rename it to something random like to reduce the risk of it being found by malicious bots.
Once you’ve identified your current PHP memory limit, you’re ready to move on to the next step to increase it.
Step 2: How to Increase PHP Memory Limit
Once you've confirmed your current PHP memory limit, you can increase it using one of these approaches. Each method works at a different level of your server's configuration, so if one doesn't work, move on to the next.
Edit wp-config.php File
The file is located in your WordPress root directory. You can access it through FTP or your hosting panel's File Manager.
Steps to follow: Open the file and find this line: (or "Happy blogging"). Right above this line, add the following code: Save the file and re-upload it to your server.
This code increases memory for front-end tasks. To boost memory for administrative functions, add this line just below it:
"This setting increases PHP Memory only for WordPress, not other applications." - WordPress Developer Resources
Note: This method only works within the limits set by your hosting provider. As Karol K from Themeisle points out, "WordPress cannot override the server's hard limit if the host has one. For example, if the server caps PHP memory at 64MB, setting WP_MEMORY_LIMIT to 256M won't give you 256MB."
Site Complexity | Recommended Memory Limit |
Small personal blogs or brochure sites | 128M |
Medium business sites using page builders (e.g., Elementor) | 256M |
Large e-commerce (WooCommerce) or membership sites | 512M |
If this doesn't work, try modifying the file.
Modify .htaccess File
This method is specific to Apache servers running . It won't work on Nginx or servers using PHP in CGI/FastCGI mode.
To locate the file, enable "Show Hidden Files" in your FTP client or File Manager. Backup the file, then open it and add this line at the very beginning: .
Save and re-upload the file. If your site shows a 500 error after saving, delete the line you added to restore functionality. To confirm the change, use the Site Health tool under Tools > Site Health > Info > Server.
If this doesn't work, move on to editing the file.
Edit php.ini File
The file is PHP's main configuration file, so changes here affect all PHP applications. This makes it a more reliable method than editing or .
On shared hosting, you might not have access to the global file, but you can create a custom one. Here's how:
Create a new text file and add this line:
Save the file as .
Upload it to your WordPress root directory (usually ) via FTP.
For VPS or dedicated servers, locate the active file. You can find its location via Tools > Site Health > Info > Server in WordPress or by creating a file. Common paths include:
(for Apache)
(for Nginx)
Open the file, search for , and set it to . Save the changes and ensure the file permissions are set to . If you're on a VPS or dedicated server, restart your web server or PHP service using commands like: or .
For an easier option, use your hosting control panel.
Use Your Hosting Control Panel
Most hosting providers offer a user-friendly interface for adjusting PHP settings. Log in to your hosting control panel and look for the PHP configuration tool. Find the setting, increase it to your desired value (e.g., 256M or 512M), and click "Apply" or "Save Changes." The control panel handles the technical details, making this approach ideal for beginners.
After making changes using any of these methods, check your new PHP memory limit in the Site Health tool to confirm it worked. If none of these methods work, your hosting provider may have a server-level cap that only they can adjust. Contact their support team for assistance.
Pro Tip: Always back up your files before making any changes. A single typo could result in a "White Screen of Death" or a 500 Internal Server Error.
Once you've successfully applied one of these methods, move on to verify your changes in the next step.
Step 3: Verify the Changes Worked
After tweaking your configuration files, it's time to confirm that the PHP memory limit has been updated. If you're using WordPress 5.2 or later, you can rely on the built-in Site Health tool to check these settings - no need for FTP or extra files.
Recheck via WordPress Site Health
Head to Tools > Site Health and select the Info tab. Start by expanding the Server section to find the "PHP memory limit" entry. This tells you the maximum memory your server allows. Then, scroll down to the WordPress Constants section to review the values for (used for front-end operations) and (applies to the admin dashboard).
Remember, the memory limit you define in the file cannot exceed the server's hard limit. As Ben Oates puts it, "The WordPress PHP limit can never be higher than [the server limit]". If Site Health still shows the old values after your changes, it's likely because your hosting provider has set a hard cap, which only they can modify.
Tip: Clear all caches to ensure the Site Health tool reflects the updated settings accurately.
Once you've verified the new limits in Site Health, it's time to test your site's functionality.
Test Your WordPress Site
Looking at technical data is just one part of the process - you also need to ensure your site runs smoothly. Test the action that previously caused issues, whether it was running a backup, using a page builder, or uploading large files.
If the error persists despite increasing the memory limit, you might be dealing with a memory leak or a poorly coded plugin. Matteo Duò, Head of Content at Kinsta, advises, "In 90% of cases, you should never need to raise the memory limit past 256 MB". To dig deeper, use a diagnostic tool like Query Monitor to pinpoint plugins or processes consuming excessive memory.
How WPWorld Handles PHP Memory Automatically
WPWorld takes the hassle out of managing PHP memory by automating resource allocation at the server level. No need for manual tweaks or file edits - this hosting platform ensures your site gets the resources it requires, eliminating memory exhaustion errors. With WPWorld, resource management becomes effortless, thanks to unlimited RAM and CPU included in all plans.
Unlimited RAM on All Plans
WPWorld’s hosting environment is built on an optimized NGINX LEMP stack with PHP-FPM, which removes memory limitations entirely. Instead of requiring users to modify configuration files - changes that might be restricted by hosting providers - WPWorld handles everything behind the scenes. PHP-FPM pools and NGINX FastCGI parameters are automatically adjusted to meet your site’s demands. This means whether you’re running WooCommerce transactions, uploading high-resolution images, or dealing with sudden traffic surges, your site stays responsive without any manual input.
The platform also includes real-time monitoring and integrates advanced server-level caching strategies like Redis and FastCGI, along with a CDN, ensuring your site performs well under heavy loads. To top it off, an auto-healing system proactively resolves resource issues before they can impact your site’s performance.
Other WPWorld Features
WPWorld doesn’t just stop at unlimited resources. It also simplifies WordPress management with a suite of additional features, including:
24/7 engineer support to assist you anytime.
Automated security updates and firewall management (7G/8G).
Free domain registration, SSL, and CDN for enhanced security and performance.
Daily backups to protect your data.
Unmetered traffic and free email inboxes included in all plans.
An advanced control panel for easy site administration.
With plans starting at $15.95 per month, WPWorld delivers a comprehensive hosting solution designed to keep your WordPress site running smoothly and efficiently.
Conclusion
Why PHP Memory Matters
Boosting your PHP memory limit isn't just a technical tweak - it’s a cornerstone for maintaining a fast and reliable WordPress site. Today’s WordPress setups often rely on resource-heavy tools like WooCommerce, Elementor, and various security plugins. These tools demand considerable memory to handle tasks like processing customer data, managing intricate designs, and running essential backend operations such as media uploads or backups. Without enough memory, your site can suffer from slow load times, sluggish admin dashboards, and even interruptions in critical functions.
The PHP memory limit also serves as a safeguard, ensuring that a single malfunctioning script doesn’t crash your entire server. While WordPress defaults to 40 MB for single sites and 64 MB for multisite installations, modern sites typically need more. For basic setups, 128 MB is often sufficient, but sites using page builders or e-commerce platforms may require 256 MB or even 512 MB to handle complex tasks like database queries and inventory management. As Itamar Haim, SEO Team Lead at Elementor, wisely points out:
"Just increasing the memory limit is a temporary patch. A professional web creator always investigates why the memory is being used".
A properly configured PHP memory limit is essential for smooth operations, and WPWorld’s hosting removes these limitations entirely.
Why Choose WPWorld for WordPress Hosting
Tired of struggling with PHP memory issues? WPWorld offers a hassle-free solution by eliminating manual memory management entirely. Shared hosting providers often enforce strict memory caps that can’t be bypassed with code edits, but WPWorld takes a different approach. Starting at just $15.95 per month, every WPWorld plan includes unlimited RAM, ensuring your site always gets the memory it needs - without requiring you to tinker with wp-config.php tweaks, .htaccess, or php.ini files.
Beyond solving memory challenges, WPWorld provides a complete hosting package. Features like 24/7 engineer support, automated security, free domain registration, SSL, CDN, and daily backups are all included. This means your site stays fast, secure, and stable, no matter the traffic or workload. Choosing WPWorld isn’t just about avoiding memory errors - it’s about ensuring long-term performance and peace of mind. With unlimited resources, your WordPress site is ready to handle any challenge.
FAQs
How can I find my current PHP memory limit in WordPress?
To check your PHP memory limit in WordPress, you can use the Site Health tool. This feature, available in WordPress since version 5.0, gives you a clear overview of your server settings, including the PHP memory limit.
Here’s how you can find it:
Log in to your WordPress admin dashboard.
Navigate to Tools > Site Health.
Select the Info tab at the top of the page.
Scroll to the Server section, where you’ll see the PHP memory limit displayed.
This approach is straightforward and doesn’t involve modifying files or adjusting hosting settings.
What can I do if increasing PHP memory in WordPress doesn’t fix the issue?
If increasing the PHP memory limit doesn’t solve the problem, here are some additional steps to help you dig deeper:
Verify the memory limit: Use WordPress's Site Health tool or check your server settings to ensure the memory limit was successfully updated.
Check plugins and themes: Sometimes, a problematic plugin or theme is the culprit. Try deactivating all plugins or switching to a default theme to pinpoint the issue.
Examine server logs: Server logs can reveal errors or restrictions that might be causing the problem.
If none of these steps work, consider contacting your hosting provider for support or look into optimizing your website's code to minimize resource demands.
Why should I increase the PHP memory limit for my WordPress site?
Increasing the PHP memory limit is a key step to keep your WordPress site running smoothly, especially as it becomes more complex. Without sufficient memory, you might run into errors like "Allowed memory size exhausted" or notice sluggish performance when using themes or plugins that require a lot of resources.
By bumping up the memory limit, your site can handle more demanding tasks with ease, minimizing the chances of crashes, slowdowns, or other performance hiccups. This adjustment helps maintain a faster, more reliable site for both you and your visitors.



Comments