How to customize “artisan down” page? in laravel 12

In Laravel 12, the php artisan down command puts your application into maintenance mode — displaying a default “503 Service Unavailable” page to visitors. But you can easily customize this page to better match your brand, add useful info, or show a countdown.

Here’s a step-by-step guide to customize the maintenance mode page in Laravel 12:


🚧 What Happens During php artisan down?

When you run:

php artisan down

Laravel:

  • Creates a storage/framework/maintenance.php file.
  • Shows a default 503 “Service Unavailable” page to all users except those whitelisted (via --secret or IPs).
  • Prevents all HTTP access until the app is brought back up via:
php artisan up

🎨 How to Customize the “Down for Maintenance” Page

✅ Step 1: Create the Custom View

Laravel looks for a custom maintenance view at:

resources/views/errors/503.blade.php

If this file doesn’t exist, it shows the default view.

✍️ Example: resources/views/errors/503.blade.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>We’re Under Maintenance</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        body {
            background: #f8fafc;
            color: #333;
            font-family: 'Arial', sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            flex-direction: column;
            text-align: center;
        }
        h1 {
            font-size: 48px;
            color: #6366f1;
        }
        p {
            font-size: 18px;
        }
    </style>
</head>
<body>
    <h1>🚧 Maintenance in Progress</h1>
    <p>We’re currently working on updates.<br>
    Please check back in a few minutes.</p>
</body>
</html>

This will replace the default Laravel maintenance page.


🛠️ Optional: Pass Custom Message to the Page

You can pass a message via artisan down:

php artisan down --message="Upgrading database..."

Then in your Blade view, access it like this:

<p>{{ $exception->getMessage() ?: 'We’ll be back soon.' }}</p>

getMessage() contains the value passed to --message.


🔐 Optional: Use --secret to Let Admins Bypass

You can generate a secret token to let certain users access the site during maintenance:

php artisan down --secret="my-secret-code"

Now, visiting:

https://yourdomain.com/my-secret-code

Will let you bypass the maintenance page.


🧪 Test Your Customization

After creating 503.blade.php, run:

php artisan down

Then open your site in the browser — your custom design will be shown!

When you’re ready to go live again:

php artisan up

📁 File Summary

FilePurpose
resources/views/errors/503.blade.phpYour custom maintenance mode page
storage/framework/maintenance.phpLaravel’s internal maintenance trigger

✅ Summary

To customize the artisan down maintenance page in Laravel 12:

  1. Create resources/views/errors/503.blade.php
  2. Design it with your own HTML/CSS/message
  3. Use --message or --secret options as needed
  4. Run php artisan down to activate it
  5. Run php artisan up to bring the site back


Leave a Reply

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