Lesson 9.2: Maintenance mode
Before an upgrade, an import or a restore, the public site should stop taking changes and show visitors an honest "back soon" page. Maintenance mode does that: every page request gets a maintenance page with status 503, while the administration stays reachable to bring the site back. This lesson covers the page, the command line and the way back in when something goes wrong.
Note
Maintenance mode takes the whole public site offline. Use your own training installation only.
At a glance
| Course | Site administration |
| Module | Module 9: Backups and maintenance |
| Duration | 40 minutes (15 presenting, 25 exercise) |
| Level | Intermediate |
| Audience | Site administrators, support staff |
| Prerequisites | Lesson 9.1; an administrator account and a shell on the training installation |
Learning objectives
After this lesson, learners can:
- take the public site offline from Setup > Maintenance with a message, a duration and allowed addresses;
- check what a visitor gets (status 503 and the maintenance page) with
curl; - bring the site back online and read Recent changes;
- do the same from a shell, and explain what
--allow-adminchanges; - get back in by removing
var/maintenance.jsonwhen nothing else works.
Trainer's notes
How to present it
Source: Maintenance mode: taking the site offline and bringing it back, sections 1 to 7 and 15. The page described is the one of the admin4 design.
- What it does (3 minutes). Every page request gets the maintenance page with
503 Service Unavailable,Retry-Afterandno-store. Images, styles and scripts are still served. The administration under/adminstays reachable. - The page (5 minutes). Setup, then Maintenance. Show Plan the maintenance window: Message for visitors (optional), Expected duration in minutes (optional) with the buttons 15 min to 4 h, Let my own address ... still see the site, Other addresses that still see the site (optional), the confirmation tick and Take the site offline. Show Preview: what visitors will see.
- While offline (2 minutes). An amber banner says why, by whom, since when, until when and whether you see the site. Maintenance never ends by itself when the expected time passes: Bring the site back online ends it.
- The shell (3 minutes).
php bin/php/maintenance.php on|off|status, orphp bin/php/console exp:maintenance. Without--allow-adminthe administration is offline too. - The way back in (2 minutes). The whole state is one file,
var/maintenance.json. Deleting it ends maintenance.
Common questions
Do cronjobs stop during maintenance? Not by themselves. Stop the crontab for the window or pause the parts (Module 6), and run them afterwards.
I switched it on but I still see the site. Your address is allowed, or a CDN still holds the page. Look at You
in the banner and check with curl -sI from another address.
Is every switch recorded? Yes: as system.maintenance.change in the audit; the page lists the latest eight.
Pitfalls
- An administration on its own host. If the administration is not under
/admin, switching on from the page can lock it out. Know the shell command before you start. - Old pages after the window. A cache in front of PHP kept pages from before. Clear Velocity's response cache and purge the CDN.
- Restoring
var/taken during maintenance. The restored site comes back in maintenance; switch it off.
Hands-on exercise
Use your own training installation, served for example on http://127.0.0.1:8087; replace the address with yours.
As administrator, open Setup > Maintenance. Read The site is online and How it works.
Type a Message for visitors (optional):
Training: back in 15 minutes. Press 15 min.Leave Let my own address ... still see the site unticked. Read Preview: what visitors will see.
Tick the confirmation and press Take the site offline. Read the banner.
In a terminal, check what a visitor gets:
curl -sI http://127.0.0.1:8087/ | head -5Open the administration's dashboard in another tab: it still works.
Press Bring the site back online. Run the
curlcommand again.Now from the shell, keeping the administration reachable:
php bin/php/maintenance.php on --message="Training from the shell" --until=30m --allow-admin php bin/php/maintenance.php statusReload Setup > Maintenance. The banner shows the shell's switch; Recent changes lists both windows.
Practise the way back in:
ls -l var/maintenance.json, then end maintenance withphp bin/php/maintenance.php off. Your trainer shows the last resort, deleting the file, on the projector.
Expected result
- Step 5 shows
HTTP/1.1 503 Service Unavailable(or HTTP/2 503) and aRetry-Afterheader. - Step 6: the administration answers normally.
- After step 7 the
curlshows200again. - Step 8
statusreports maintenance as on, with the message and the expected end. - After step 10
var/maintenance.jsonno longer exists and the site answers200. - The trainer checks Recent changes on one learner's page: two windows, each switched on and off.

Quiz
- What HTTP status does a visitor get during maintenance? A. 200 B. 404 C. 500 D. 503
- True or false: maintenance ends by itself when the expected duration has passed.
- What does
--allow-adminchange on the command line? - You are locked out of the administration and the site shows the maintenance page. What do you do?
- Why should cronjobs be paused for a maintenance window?
Answers
- D. With
Retry-Afterandno-store(Maintenance mode, In short). - False. It ends only when someone switches it off.
- It keeps the administration under
/adminreachable; without it the administration is offline too. - In a shell:
php bin/php/maintenance.php off; if PHP cannot run, deletevar/maintenance.json(Troubleshooting). - They keep running against a site that is being changed and can fail or write half-finished data.
Further reading
- Maintenance mode: the full guide, including caches and deploys.
- Maintenance mode feature reference.
- Maintenance mode for hosts.
Related pages
- Module 9: Backups and maintenance
- Site administration: course overview
- Trainers: start here
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.