How-to guide

    Magento 2 Maintenance Mode Done Properly

    Enable It, Keep Your Own Access, and Get Out Cleanly

    By Simon Bumford, Founder of EveryHost9 min read

    TL;DR

    Magento 2 maintenance mode is one command each way: bin/magento maintenance:enable to close the storefront, bin/magento maintenance:disable to reopen it. Add your own IP with the --ip option so you can still browse the store while everyone else sees a 503 maintenance page. Under the surface it is nothing more than a flag file, var/.maintenance.flag, which is also why stores get stuck in maintenance mode after upgrades: a leftover flag file keeps the shutters down. The 503 status matters, because it tells crawlers to come back rather than deindex you. Keep windows short, do the real work in staging, and reserve maintenance mode for cutover moments.

    What maintenance mode actually does

    Maintenance mode takes your storefront offline in a controlled way. While it is on, ordinary visitors receive an HTTP 503 response with a maintenance page served from the pub/errors directory, and Magento stops processing storefront requests. Customers cannot browse, add to basket or check out, which is exactly what you want while the database schema is changing halfway through an upgrade. A half-migrated store that still takes orders is far worse than a store that is politely closed for twenty minutes.

    The mechanism is refreshingly simple. Magento checks for a single file on every request: var/.maintenance.flag. If the file exists, the store is in maintenance mode. If it does not, the store is live. There is no database setting, no admin toggle and no hidden state. A second file, var/.maintenance.ip, holds the list of IP addresses that are allowed through while the flag is up. Everything the CLI commands below do comes down to creating, reading and deleting those two files.

    Knowing that is worth more than it sounds. When a deployment tool dies mid-run and leaves your store showing the maintenance page at 2am, you do not need to remember a command: you need to know that deleting one file brings the store back.

    Visitors & crawlerspublic traffic503 maintenancevar/.maintenance.flag presentcrawler told: temporary, return later200 liveflag file removedstorefront serving normallyYou (allowed IP)var/.maintenance.ipbypasses the maintenance pagesees the real storefront while it is closed
    While the flag file exists the public gets a 503 and crawlers are told to return later. Allowed IPs skip the maintenance page entirely.

    The three commands you need

    Everything runs from the Magento root directory on your server, as the user that owns the Magento files. To close the storefront:

    bin/magento maintenance:enable

    To reopen it when the work is finished:

    bin/magento maintenance:disable

    And to check where you stand, which is worth doing before and after any maintenance window, especially one somebody else started:

    bin/magento maintenance:status

    The status command reports whether maintenance mode is active and which IP addresses are currently on the allow list. If a colleague tells you "the site is down" during a planned window, thirty seconds with maintenance:status separates "working as intended" from a real incident.

    Allow your own IP so you can still see the store

    A maintenance window where nobody can check the site is a maintenance window flown blind. Magento lets you exempt specific IP addresses, so you and your developer see the real storefront while the public sees the 503 page. Pass the addresses when you enable maintenance mode:

    bin/magento maintenance:enable --ip=1.2.3.4 --ip=5.6.7.8

    Or manage the list separately, before or during a window:

    bin/magento maintenance:allow-ips 1.2.3.4

    The addresses are written to var/.maintenance.ip, one list for the whole installation. Add your office connection, your home connection and your agency's egress IP before a planned upgrade, then walk the store as a customer would while it is closed: home page, category page, product page, basket, checkout. Five minutes of clicking through on an allowed IP has caught many a broken deployment before the store reopened to the public.

    One practical caveat: if your broadband provider rotates your IP address mid-window, you will suddenly see the maintenance page like everyone else. Nothing is broken. Look up your new public IP and run maintenance:allow-ips again with the fresh address included.

    The flag file, and why stores get stuck

    Because maintenance mode is just a file check, you can operate it without the CLI at all. Creating an empty file at var/.maintenance.flag closes the store; deleting it reopens the store. This is genuinely useful when CLI access is awkward: a deployment pipeline can touch and remove the flag as build steps, and if you only have SFTP or a file manager to hand, creating or deleting one file is all it takes.

    touch var/.maintenance.flag   # store closed
    rm var/.maintenance.flag      # store open

    The same simplicity explains the most common maintenance mode problem: the store that stays stuck on the 503 page after an upgrade has finished. An interrupted setup:upgrade, a deploy script that crashed before its cleanup step, or a developer who simply forgot, and the flag file sits there keeping the shutters down indefinitely. The fix is the same every time: run bin/magento maintenance:disable, or delete var/.maintenance.flag by hand, and the store returns instantly. If it does not, the flag was never your problem, and the real error will be waiting in var/log/exception.log.

    It is also worth knowing what maintenance mode does not do. It does not stop cron jobs, so indexing and email sending carry on in the background, and it does not block the CLI itself, which is the point: you take the storefront offline precisely so that setup:upgrade and friends can run against a quiet database.

    The 503 page: customising it, and why the status code matters

    The default maintenance page is functional and unbranded. It lives in pub/errors, outside your theme, because it has to work even when Magento itself cannot fully boot. To put your own branding on it, copy the default error skin inside pub/errors to a new folder, adjust the markup and stylesheet, then create a pub/errors/local.xml file that points the skin setting at your folder. From then on, planned windows show customers your logo and, ideally, one honest sentence: back within the hour. That single line converts an alarming dead end into a non-event.

    Whatever the page looks like, the part search engines care about is invisible: the HTTP 503 status code. A 503 is the web's "temporarily unavailable" signal. Googlebot receives it, keeps your pages in the index, and schedules a retry. That is why a short maintenance window, an hour for an upgrade, even a morning for a big migration, does not cost you rankings that took years to build.

    Two behaviours do cause damage. The first is staying in maintenance mode for a long time: after repeated 503 visits over a period of days, crawlers start treating the outage as permanent and pages begin dropping from the index. The second is the DIY holding page that returns 200 OK: to Google, that thin "we'll be back soon" page is now the live content of every URL it appears on, and it can replace your product pages in the index. Magento's built-in maintenance mode sends the correct 503 for you, which is a strong reason to use it instead of improvising at the web server level. If a window is going to run long, put a proper Retry-After value on the response and, more importantly, question why the work is not happening in staging.

    When maintenance mode is the right tool

    Maintenance mode is for moments when the live store's code and database are changing in ways that could break a customer mid-checkout. In practice that means four situations: Magento version upgrades, such as the move off 2.4.6 covered in our Magento 2.4.6 end of life guide; extension installs or removals on production when no staging environment exists; data and server migrations; and emergency incident response, where closing the store deliberately beats letting it fail publicly while you work.

    What it is not for is routine development. The store that spends every Tuesday afternoon behind a 503 page is losing orders and testing Google's patience for no reason. The pattern that scales is to do the real work in a staging copy of the store, prove it there, and reserve maintenance mode on production for the short cutover moment when the tested change is applied. On EveryHost plans a staging environment is included exactly for this, and on managed Magento 2 hosting our engineers handle the maintenance windows themselves: we schedule them for your quiet hours, allow the right IPs, run the work and confirm the store is back before anyone notices. That workflow, staging first with short production windows, is standard on every specialist Magento 2 hosting UK plan we build, with the stack built to your store's required versions rather than a one-size install.

    A note if you found this looking for Magento 1

    Older guides describe a maintenance.flag file placed in the web root, with index.php edited by hand to let your own IP through. That was Magento 1, and it worked, but Magento 1 reached end of life in June 2020: no security patches, shrinking PCI defensibility, and an ecosystem that has moved on. If your store still runs on it, the productive next step is not a better maintenance page but a migration to a supported Magento 2 version. Everything above applies the day you arrive.

    Frequently Asked Questions

    Frequently Asked Questions

    Not if you use it properly. Magento maintenance mode returns an HTTP 503 status, which tells Google and other crawlers the site is temporarily unavailable and they should come back later. Short windows, an hour or two for an upgrade or a cutover, do not cause pages to drop out of the index. The damage comes from leaving the store in maintenance mode for days at a time, because crawlers that repeatedly receive 503 responses will eventually start dropping pages. The other trap is serving a maintenance page with a 200 status: Google then treats the holding page as your real content and may index it in place of your product pages. Magento's built-in maintenance mode gets the status code right, so the safest approach is to use it and keep windows short.

    Add your own IP address to the allow list. Either pass it when you enable maintenance mode with bin/magento maintenance:enable --ip=YOUR.IP.ADDRESS, or set it afterwards with bin/magento maintenance:allow-ips YOUR.IP.ADDRESS. Magento stores the allowed addresses in var/.maintenance.ip and serves the normal storefront to those IPs while everyone else sees the 503 page. You can list several addresses, so your developer, your agency and your office connection can all keep browsing the store while the public sees the maintenance page. Find your current public IP by searching "what is my IP" before you start.

    This is almost always a leftover flag file. Magento checks for the file var/.maintenance.flag on every request, and if a deploy script or an interrupted upgrade left it behind, the store stays on the 503 page even though the work has finished. Run bin/magento maintenance:disable from the Magento root directory, or simply delete var/.maintenance.flag by hand and the store comes straight back. If the site is still down after the flag is removed, the problem is something else, usually a failed setup:upgrade or a broken cache, and the errors in var/log will tell you what.

    Yes. The maintenance page is served from the pub/errors directory, not from your theme. Copy the default error skin to a new folder inside pub/errors, edit the templates and stylesheet to match your brand, then create pub/errors/local.xml with the skin setting pointed at your new folder. Magento will then serve your branded page for maintenance windows and error states. A short message telling customers when you expect to be back is worth adding: it turns a dead end into a reassurance. The 503 status code is still sent regardless of what the page looks like, so a custom page costs you nothing in SEO terms.

    They are unrelated features that get confused because both are switched from the command line. Maintenance mode (bin/magento maintenance:enable) takes the storefront offline for visitors and serves a 503 page while you work. Developer mode (bin/magento deploy:mode:set developer) changes how Magento runs: it disables static file caching, shows detailed exceptions and recompiles code on the fly, and it is meant for development environments, never production. Putting a production store into developer mode makes it dramatically slower and can leak error detail to visitors. If you want to work on a live server safely, use maintenance mode with your IP allowed, and leave the deploy mode set to production.

    No. Most day-to-day work belongs in a staging environment, and routine deployments on a properly configured server do not need the store taken offline at all. Maintenance mode is for the moments when the live database and code are changing underneath customers in ways that could break checkout: version upgrades, database migrations, risky extension installs and emergency incident response. On EveryHost plans a staging environment is included, so the pattern we recommend is simple: build and test in staging, then use a short maintenance window on production only for the final cutover.

    Sources and further reading

    • Adobe Experience League, Enable or disable maintenance mode (Magento 2 installation guide)
    • Adobe Experience League, Create the custom maintenance page (pub/errors and local.xml)
    • Google Search Central, Pause or disable your online business: HTTP 503 best practice
    • Adobe, Magento 1 end of support announcement (June 2020)

    Want maintenance windows you never have to think about?

    On EveryHost managed plans, our UK engineers schedule the window, run the upgrade in staging first, and reopen the store before your customers notice. Staging included, stack built to your store's required versions.