• Email: [email protected]
  • Dedicated Server Login
  • About
  • 9288041031
  • Knowledge Base
  • Support
India's best web hosting | Ehostpiya India
  • Home
  • Hosting
    Web Hosting Quality Hosting Starting at ₹60/mo
    Cloud VPS Starting at ₹300/mo
    Dedicated Server First Starting at ₹2401/mo
    Reseller Web Hosting Conveniently Starting at ₹421/mo
    Application For Hosting
    • iconWordPress Hosting
    • iconJoomla Hosting
    • iconMagento Hosting
    • iconOpencart Hosting
    • iconPrestashop Hosting
    • iconDrupal Hosting
  • Email
  • Domain
  • SVG
    Contact Us Face any problem contact with us
    SVG
    About Us We are leading hosting company
  • My Account
Web Hosting Blogs by Ehostpiya | Tips and Tricks Web Hosting Blogs by Ehostpiya | Tips and Tricks
Buy Now

Archives

  • October 2026
  • September 2026
  • August 2026
  • October 2023

Categories

  • Control Panels
  • Magento
  • Miscellaneous
  • SEO
  • Technology
  • Trends
  • Web Hosting
  • Wordpress
Facebook Twitter Instagram Pinterest
Home How to Increase Magento PHP Memory Limit?
ByVandeeta
October 6, 2026

How to Increase Magento PHP Memory Limit?

Table of Contents

Toggle
  • How to Increase Magento PHP Memory Limit
    • What Is the PHP Memory Limit?
    • 1. Check the Current PHP Memory Limit
    • 2. Increase Memory Limit Using php.ini
    • 3. Increase Memory Limit for Magento CLI
    • 4. Increase Memory Limit Using .user.ini
    • 5. Increase Memory Limit Using .htaccess
    • 6. Change PHP Memory Limit in DirectAdmin
    • 7. Change PHP Memory Limit in cPanel
    • 8. Verify the New Memory Limit
    • 9. Choose an Appropriate Memory Limit
    • 10. Don’t Confuse PHP Memory Limit With Server RAM
    • 11. Common Magento Memory Error
    • 12. Restart PHP-FPM After Changes
    • Troubleshooting
      • The memory limit didn’t change
      • Magento still reports the old limit
      • Increasing memory doesn’t solve the problem
    • Conclusion

How to Increase Magento PHP Memory Limit

Magento can require a significant amount of PHP memory, particularly when installing extensions, importing products, running Magento CLI commands, compiling code, indexing, or performing upgrades. If the PHP memory limit is too low, Magento may display errors such as “Allowed memory size exhausted.”

Increasing the PHP memory limit gives PHP more memory to complete resource-intensive Magento operations.

What Is the PHP Memory Limit?

The PHP memory_limit setting determines the maximum amount of RAM that a single PHP process can use.

For example:

memory_limit = 512M

means one PHP process can use up to approximately 512 MB of memory.

For Magento, 512M is a common starting point, although the appropriate value depends on your Magento version, workload, extensions, and server resources.


1. Check the Current PHP Memory Limit

Before changing anything, check the current value.

From the command line:

php -i | grep memory_limit

You may see:

memory_limit => 256M => 256M

You can also create a temporary PHP information page containing:

<?php
phpinfo();

Open the file in your browser and search for memory_limit.

Remove the phpinfo() file after checking it because it exposes detailed server configuration.


2. Increase Memory Limit Using php.ini

The most common method is to modify the PHP configuration file.

First find the loaded PHP configuration:

php --ini

You may see something similar to:

Loaded Configuration File: /etc/php/8.2/cli/php.ini

Open the appropriate php.ini file:

nano /etc/php/8.2/fpm/php.ini

Find:

memory_limit = 256M

Change it to:

memory_limit = 512M

Save the file.

Then restart PHP-FPM:

systemctl restart php8.2-fpm

The exact service name depends on your installed PHP version.


3. Increase Memory Limit for Magento CLI

One important detail is that CLI PHP and web PHP can use different configuration files.

Check the CLI limit:

php -i | grep memory_limit

If Magento CLI commands require more memory, you can temporarily run a command with a higher limit:

php -d memory_limit=2G bin/magento cache:flush

For example, when running a resource-intensive operation:

php -d memory_limit=2G bin/magento indexer:reindex

This changes the memory limit only for that command.


4. Increase Memory Limit Using .user.ini

On hosting environments where you cannot edit the main php.ini, you may be able to use .user.ini.

Create or edit:

.user.ini

Add:

memory_limit = 512M

Place the file in the appropriate Magento web directory, commonly the site’s document root.

Depending on the PHP configuration, it may take some time for PHP to recognize changes to .user.ini.


5. Increase Memory Limit Using .htaccess

On Apache servers using PHP as an appropriate module, you may be able to set the limit through .htaccess:

php_value memory_limit 512M

However, this method does not work with every PHP setup, particularly common PHP-FPM configurations.

If it causes an HTTP 500 error, remove the setting and configure the limit through php.ini, .user.ini, or your hosting control panel instead.


6. Change PHP Memory Limit in DirectAdmin

If your Magento website is hosted with DirectAdmin, you may be able to change the PHP memory limit from the control panel.

Depending on the DirectAdmin configuration:

  1. Log in to DirectAdmin.
  2. Open PHP Settings or the relevant domain PHP configuration.
  3. Locate memory_limit.
  4. Change it from something such as:256Mto:512M
  5. Save the changes.

The exact interface depends on the server’s PHP mode and DirectAdmin configuration.


7. Change PHP Memory Limit in cPanel

If you are using cPanel:

  1. Log in to cPanel.
  2. Open MultiPHP INI Editor.
  3. Select your Magento domain.
  4. Find memory_limit.
  5. Set it to:512M
  6. Save the configuration.

You can then verify the setting from the command line or with a temporary PHP information page.


8. Verify the New Memory Limit

After changing the configuration, verify it.

For CLI PHP:

php -i | grep memory_limit

You should see:

memory_limit => 512M => 512M

For web requests, verify the PHP-FPM/web PHP configuration separately because it may use a different php.ini.


9. Choose an Appropriate Memory Limit

There is no single value that is correct for every Magento installation.

A general starting point could be:

Magento TaskSuggested Starting Point
Normal storefront512M
Magento CLI operations1G
Large catalog operations1–2G
Large imports/indexing1–2G+
Magento upgrades1–2G

These are starting points, not mandatory requirements. Your server must have enough available RAM to support the selected limits.

For example, setting:

memory_limit = 4G

does not automatically make Magento faster. If many PHP processes are allowed to consume several gigabytes simultaneously, the server can run out of RAM.


10. Don’t Confuse PHP Memory Limit With Server RAM

These are different settings.

For example, a server might have:

RAM:              16 GB
PHP memory_limit: 512 MB

The 512M limit applies to an individual PHP process. It does not mean that the entire server has only 512 MB available.

Similarly, increasing the PHP memory limit does not increase the physical RAM installed on the server.


11. Common Magento Memory Error

You may encounter an error similar to:

Fatal error: Allowed memory size of 268435456 bytes exhausted

This means PHP reached its configured memory limit.

For example:

268435456 bytes = 256 MB

Increasing the limit to:

memory_limit = 512M

may resolve the immediate problem.

However, if Magento repeatedly consumes excessive memory, investigate the underlying cause rather than continuously increasing the limit.

Potential causes include:

  • Poorly coded extensions
  • Large product imports
  • Huge catalogs
  • Inefficient custom code
  • Database problems
  • Large XML/CSV processing
  • Resource-intensive indexing
  • Magento upgrade processes

12. Restart PHP-FPM After Changes

When modifying the PHP-FPM configuration, restart the appropriate PHP-FPM service.

For example:

systemctl restart php8.2-fpm

Then verify:

php -i | grep memory_limit

Remember that the CLI and web server may use different PHP configurations.


Troubleshooting

The memory limit didn’t change

Check which PHP configuration is being used:

php --ini

For web requests, check the PHP-FPM configuration or hosting control panel.

Magento still reports the old limit

You may have changed the CLI configuration while Magento’s web requests use another PHP configuration.

Check both environments separately.

Increasing memory doesn’t solve the problem

If Magento continues consuming excessive memory, investigate:

  • Extensions
  • Custom modules
  • Product imports
  • Indexers
  • Database queries
  • PHP-FPM configuration
  • Magento cron jobs

Increasing the limit indefinitely can hide the real problem.

Conclusion

Increasing Magento’s PHP memory limit is straightforward, but it should be done carefully. For many Magento installations, 512M is a reasonable starting point, while resource-intensive CLI operations may need 1G or more.

The basic process is:

Check current limit
       ↓
Choose an appropriate value
       ↓
Modify PHP configuration
       ↓
Restart PHP-FPM if required
       ↓
Verify the new value
       ↓
Test Magento operations

If Magento continues to require unusually large amounts of memory, focus on finding the underlying performance or code problem instead of simply increasing memory_limit.

ByVandeeta
Updated October 06, 2026
  • Magento

Read Next

ByVandeeta
October 6, 2026

How to Secure a Magento Store: Complete Security Guide

How to Secure a Magento Store: Complete Security Guide Magento is a powerful eCommerce platform designed for stores…
  • Magento
ByVandeeta
October 6, 2026

How to Change the Magento Admin URL?

How to Change the Magento Admin URL Changing the Magento Admin URL is a useful security measure that…
  • Magento
ByVandeeta
October 6, 2026

How to Force HTTPS in Magento?

How to Force HTTPS in Magento HTTPS is essential for a secure Magento store. It encrypts communication between…
  • Magento

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Explore Categories

  • Control Panels 7
  • Magento 52
  • Miscellaneous 5
  • SEO 17
  • Technology 10
  • Trends 9
  • Web Hosting 7
  • Wordpress 100

Recent Posts

  • How to Fix WordPress “Too Many Redirects”
  • How to Fix WordPress Critical Error
  • How to Fix WordPress Database Connection Error
  • How to Fix WordPress White Screen of Death
  • How to Fix WordPress 404 Error

Recent Comments

  1. Tabias H. on The Future is 5G: Understanding the Next Wave of Connectivity
  2. Elliot Alderson on Evolving Workspaces: The Rise of the Hybrid Work Trend
  3. James Mann on Evolving Workspaces: The Rise of the Hybrid Work Trend
Swyft

Welcome to the Ehostpiya Blog, your trusted resource for web hosting, WordPress, VPS, domains, website security, and online business tips.

Our goal is to make web hosting and website management easier to understand for everyone—from beginners launching their first website to experienced developers and business owners. We publish practical guides, hosting tips, tutorials, and helpful insights to help you build, manage, and grow your website successfully.

At Ehostpiya, we believe that reliable information and quality hosting go hand in hand. Explore our latest articles and discover simple solutions for a faster, safer, and more successful online presence.

  • Facebook
  • Twitter
  • Instagram
  • Pinteres

Featured Posts

  • AI and Ethics: Navigating the Complex Landscape of Artificial Intelligence
    by Vandeeta
    October 11, 2023
  • AR and VR: Blurring the Lines Between Reality and Virtuality
    by Vandeeta
    October 11, 2023
  • Best WordPress Caching Plugins to Improve Website Speed
    by Vandeeta
    September 26, 2026
  • Blockchain Unchained: How Distributed Ledger Technology is Transforming Industries
    by Vandeeta
    October 11, 2023

Web Hosting Discount

cLAIM NOW
logo

Ehostpiya is reliable Web hosting provider, with aim to provide affordable Website and application hosting to various clients for their online business and presence.

Hosting
  • Web Hosting
  • Cloud VPS
  • Reseller Hosting
  • Email Hosting
  • Dedicated Server
  • Nodejs Hosting
  • SSL Certificate
Legal
  • Accepted Uses Policy
  • privacy Policy
  • Terms of Service
  • Refund and cancellation
  • Service Delivery Policy
Company
  • About Us
  • Our Clients
  • Contact Us
  • Our Blog
Support & Tools
  • Open Support Request
  • View Ticket
  • Knowledge Base
  • Report Abuse
  • check nameserver
  • What is my IP
  • Mx lookup

© Ehostpiya, All rights reserved

  • Terms & Condition
  • Privacy Policy