Table of contents

laravel maintenance mode

In this post, I will show you an example of how to implement the Laravel 8 maintenance mode. If you have an update for your production server then you want to pause any transactions on your website. Laravel provides a command that will help us to do this.


Advantages of switching Laravel 8 maintenance mode

It will help us to surely not allow save, update, delete and retrieve records from DB during the maintenance mode. It will help us also that our users are not able to access the application.

To perform maintenance mode on Laravel, run the down Artisan command.

# enable maintenance mode
php artisan down

# disable maintenance mode
php artisan up

# if you want visitor refresh the page after number of seconds being set
php artisan down --retry=60


Bypassing Laravel Maintenance Mode

If you want to bypass the maintenance mode and test the updates of your Laravel application we can use the secret option and bypass using provided token. See the below example:

php artisan down --secret="1630542a-246b-4b66-afa1-dd72a4c43515"


We can also use the browser by putting the secret key with your URL. See the below example:


Take note that when accessing this hidden route, you will then be redirected to the / route of the application. Once the cookie has been issued to your browser, you will be able to browse the application normally.


Custom View for Laravel Maintenance Mode

If you want to render a specific template or blade for your Laravel maintenance mode you can add the option --render="your file name" from your views. See the below example:

# view path: resources/views/maintenance.blade.php
php artisan down --render="maintenance"


Redirect All Request to Home Page in Laravel Maintenance Mode

If you need to restrict your visitors when Laravel maintenance mode is enabled to your web pages you can redirect them to your home page. The example below will help how to do that:

php artisan down --redirect=/


Additional Note: During the maintenance mode all your job queues will pause also. I hope this topic may help you. Thank you for visiting :)