How to Enable Developer Mode in Magento 2 (CLI + Hosting Methods)
- Shubham Kundale
- eCommerce Talk
- Feb 3, 2026
- Reading time: 8 minutes

Developer Mode in Magento 2 is what you use when you’re actively building or debugging: theme work, custom modules, extension installs, and tracking down the “why” behind an error. This guide shows the safest way to switch modes via CLI, plus fallback methods for restricted hosting where SSH isn’t available.
Magento 2 modes explained
Magento 2 runs in three modes. Each one changes how Magento handles errors, caching, and generated code.
- Default mode: general-purpose mode (common on new installs)
- Developer mode: best for development and debugging (not performance-optimized)
- Production mode: best for live stores (fastest and safest)
Important: don’t keep a live store in Developer Mode. It can slow down your storefront and may expose extra error details you don’t want public.
Quick answer (copy/paste commands)
Check the current mode
php bin/magento deploy:mode:show
Enable Developer Mode
php bin/magento deploy:mode:set developer
Switch back to Production Mode
php bin/magento deploy:mode:set production
If you want a wider list of Magento CLI commands for daily work, keep this bookmarked: Complete list of SSH/CLI commands in Magento 2.
Method 1: Enable Developer Mode via SSH / CLI (recommended)
CLI is the safest and most reliable approach because Magento updates the system state properly. Run the following from your Magento root directory
(the folder where bin/magento exists).
-
Connect via SSH and go to your Magento root
-
(Optional, but recommended) Clear generated code to avoid stale classes after switching modes:
rm -rf generated/*On modern Magento 2, generated classes live under
generated/. You might see older references likevar/generationin outdated posts, but most current installs don’t use it. -
Enable Developer Mode
php bin/magento deploy:mode:set developer -
Confirm it worked
php bin/magento deploy:mode:show
After switching modes, flushing cache helps avoid confusion (especially when you’re testing template changes or debugging output):
php bin/magento cache:flush
If you’re debugging a storefront issue and you want more structure around common causes and fixes, this is a good next read: Magento troubleshooting guides on Magespark.
Method 2: Enable Developer Mode via .htaccess (shared hosting / no SSH)
Some hosts only provide FTP or a file manager and block SSH. If your server uses Apache and allows environment variables in
.htaccess, you can force Magento into Developer Mode using MAGE_MODE.
-
Open your Magento root directory (same level as
app/,bin/,vendor/). -
(Recommended) Clear generated code to prevent stale output:
rm -rf generated/* -
Edit the root
.htaccessfile and add this line near the top:SetEnv MAGE_MODE developer
Heads up: this will not work on Nginx, and it can fail on Apache if your host disables SetEnv or blocks overrides.
If it doesn’t take effect, use the next method.
Related: if you’re working on performance while switching modes (common during debugging), you’ll probably also care about frontend speed topics. Browse the performance-focused posts here: Magespark blog.
Method 3: Enable Developer Mode by editing env.php (fallback)
If you don’t have CLI access and the .htaccess approach doesn’t work, you can set the mode directly in Magento’s configuration file.
This is a practical fallback, but if you can use CLI, do that instead.
-
Open this file:
app/etc/env.php -
Look for
MAGE_MODE. If it exists, set it todeveloper. If it doesn’t exist, add it to the returned array:'MAGE_MODE' => 'developer',
If you get stuck while editing config files or your store starts throwing errors afterward, it’s usually a permissions or environment mismatch issue. In that case, switching back via CLI (when available) is the cleanest recovery path.
Common issues (and quick fixes)
“php: command not found” or wrong PHP version
Some servers require calling a specific PHP binary. Try your installed version, for example:
php8.2 bin/magento deploy:mode:set developer
Permission errors running bin/magento
This usually means the filesystem owner/group doesn’t match the user running CLI. Avoid random permission changes like chmod 777.
Fix ownership properly based on your hosting setup (or ask your sysadmin/hosting support).
If you frequently deal with deployment and permission gotchas, consider keeping a short internal runbook with your server-specific commands.
Store becomes slow after enabling Developer Mode
That’s expected. Developer Mode is for debugging and development. For live stores, switch back to Production Mode once you’re done:
php bin/magento deploy:mode:set production
FAQ
How do I check the current Magento 2 mode?
php bin/magento deploy:mode:show
Can I enable Developer Mode on a live store?
You can, but you generally shouldn’t. It can reduce performance and may expose extra diagnostic details. Use staging/local for debugging when possible, then return to Production Mode.
How do I switch back to Production Mode?
php bin/magento deploy:mode:set production
