Bird
Raised Fist0
Laravelframework~10 mins

Maintenance mode in Laravel - Step-by-Step Execution

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Concept Flow - Maintenance mode
Start Laravel App
↓
Check if Maintenance Mode is ON?
No→Serve Normal Requests
Yes↓
Serve Maintenance Page
↓
End Request
Laravel checks if maintenance mode is active before serving requests. If yes, it shows a maintenance page; otherwise, it serves the app normally.
Execution Sample
Laravel
php artisan down
// App now in maintenance mode
// Requests show maintenance page
php artisan up
// App back to normal mode
This code puts the Laravel app into maintenance mode and then brings it back to normal.
Execution Table
StepActionMaintenance Mode StatusRequest HandlingOutput
1Run 'php artisan down'ONCheck mode -> Maintenance ONMaintenance page shown
2User sends requestONServe maintenance pageUser sees maintenance message
3Run 'php artisan up'OFFCheck mode -> Maintenance OFFNormal app serves requests
4User sends requestOFFServe normal appUser sees normal app content
5EndOFFNo maintenanceNormal operation
💡 Maintenance mode OFF, app serves normal requests
Variable Tracker
VariableStartAfter Step 1After Step 3Final
maintenance_modeOFFONOFFOFF
Key Moments - 3 Insights
Why does the app show a maintenance page after running 'php artisan down'?
Because the maintenance_mode variable changes to ON at Step 1, so Laravel serves the maintenance page as shown in Step 2.
What happens if you try to access the app while maintenance mode is ON?
The app serves the maintenance page instead of normal content, as seen in Step 2 of the execution table.
How do you bring the app back to normal operation?
By running 'php artisan up' which sets maintenance_mode to OFF at Step 3, allowing normal requests to be served.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the maintenance_mode status after running 'php artisan down'?
AUNKNOWN
BOFF
CON
DERROR
💡 Hint
Check Step 1 in the execution_table under 'Maintenance Mode Status'
At which step does the app start serving normal requests again?
AStep 2
BStep 4
CStep 3
DStep 1
💡 Hint
Look at 'Request Handling' and 'Output' columns in execution_table rows
If you skip running 'php artisan up', what will users see when they send requests?
AMaintenance page
BError 404
CNormal app content
DBlank page
💡 Hint
Refer to Step 2 where maintenance_mode is ON and maintenance page is served
Concept Snapshot
Laravel Maintenance Mode:
- Run 'php artisan down' to enable maintenance mode.
- While ON, users see a maintenance page.
- Run 'php artisan up' to disable and return to normal.
- Laravel checks mode on each request.
- Useful for safe app updates.
Full Transcript
Laravel maintenance mode lets you temporarily disable your app for users by running 'php artisan down'. When enabled, Laravel shows a maintenance page instead of normal content. This is useful during updates or fixes. To return to normal, run 'php artisan up'. The app checks the maintenance mode status on every request and serves content accordingly.

Practice

(1/5)
1. What does enabling maintenance mode in Laravel do?
easy
A. Deletes all application data
B. Automatically updates the application
C. Temporarily stops user access to the application
D. Restarts the web server

Solution

  1. Step 1: Understand maintenance mode purpose

    Maintenance mode is designed to prevent users from accessing the app temporarily during updates or fixes.
  2. Step 2: Identify what happens when enabled

    When enabled, users see a maintenance page instead of the app, stopping normal access.
  3. Final Answer:

    Temporarily stops user access to the application -> Option C
  4. Quick Check:

    Maintenance mode = stops user access [OK]
Hint: Maintenance mode blocks users temporarily [OK]
Common Mistakes:
  • Thinking it deletes data
  • Assuming it updates app automatically
  • Confusing with server restart
2. Which command correctly enables maintenance mode in Laravel?
easy
A. php artisan down
B. php artisan up
C. php artisan start
D. php artisan maintenance

Solution

  1. Step 1: Recall Laravel maintenance commands

    To enable maintenance mode, the command is php artisan down.
  2. Step 2: Verify other commands

    php artisan up disables maintenance mode; others are invalid.
  3. Final Answer:

    php artisan down -> Option A
  4. Quick Check:

    Enable maintenance = php artisan down [OK]
Hint: Use 'down' to enable maintenance mode [OK]
Common Mistakes:
  • Using 'php artisan up' to enable
  • Typing non-existent commands
  • Confusing start with down
3. What will be the output when a user visits the Laravel app URL while maintenance mode is enabled?
medium
A. The normal application homepage loads
B. A 404 Not Found error appears
C. The user is redirected to the login page
D. A 503 Service Unavailable maintenance page is shown

Solution

  1. Step 1: Understand Laravel's maintenance response

    When maintenance mode is enabled, Laravel returns a 503 status with a maintenance page.
  2. Step 2: Check other options

    The normal homepage does not load, a 404 Not Found error is unrelated, and users are not redirected to the login page.
  3. Final Answer:

    A 503 Service Unavailable maintenance page is shown -> Option D
  4. Quick Check:

    Maintenance mode shows 503 page [OK]
Hint: Maintenance mode returns 503 status page [OK]
Common Mistakes:
  • Expecting normal homepage
  • Confusing 404 with maintenance
  • Thinking it redirects to login
4. You ran php artisan down but users still access the app normally. What is the likely problem?
medium
A. The down command was run in the wrong directory
B. You need to restart the web server manually
C. You forgot to clear the cache after enabling maintenance mode
D. Maintenance mode only works in production environment

Solution

  1. Step 1: Check command context

    Running php artisan down outside the Laravel project folder does nothing.
  2. Step 2: Evaluate other options

    Cache clearing is not required; web server restart is unnecessary; maintenance mode works in all environments.
  3. Final Answer:

    The down command was run in the wrong directory -> Option A
  4. Quick Check:

    Run artisan commands in project folder [OK]
Hint: Run artisan commands inside Laravel project folder [OK]
Common Mistakes:
  • Assuming cache clear is needed
  • Restarting server unnecessarily
  • Thinking maintenance mode is environment-limited
5. How can you allow a specific IP address to access the Laravel app while it is in maintenance mode?
hard
A. Maintenance mode cannot allow exceptions for IP addresses
B. Use php artisan down --allow=IP_ADDRESS to whitelist the IP
C. Add the IP to config/app.php under 'maintenance_ips'
D. Edit .env to add the IP under MAINTENANCE_ALLOWED_IP

Solution

  1. Step 1: Recall Laravel maintenance mode options

    Laravel supports allowing IPs during maintenance using php artisan down --allow=IP_ADDRESS.
  2. Step 2: Verify other options

    Environment variables or config files do not control allowed IPs by default; maintenance mode does allow exceptions.
  3. Final Answer:

    Use php artisan down --allow=IP_ADDRESS to whitelist the IP -> Option B
  4. Quick Check:

    Allow IP with artisan down --allow [OK]
Hint: Use --allow option with down command [OK]
Common Mistakes:
  • Editing .env for allowed IPs
  • Modifying config/app.php incorrectly
  • Believing exceptions are impossible