How to bypass maintenance mode in Laravel 6 and 7

What is maintenance mode?

Maintenance mode in Laravel prevents users from accessing the application.

This is usually done when you want to carry out an update, upgrade, or debug errors from the application.

You can set your application to maintenance mode by running the following command:

php artisan down

Applications become inaccessible when they are in maintenance mode.

It is possible to bypass maintenance mode so that only you can access your application. To do this, you need to perform the following steps:

  • Step 1: Install the haruncpi/laravel-maintenance package using the composer, as shown below:
composer require haruncpi/laravel-maintenance
  • Step 2: Edit the maintenance middleware app/Http/Kernel.php file, so that it resembles the following:
//\App\Http\Middleware\CheckForMaintenanceMode::class,
\Haruncpi\LaravelMaintenance\Middleware\MaintenanceMode::class,
  • Step 3: Run the below command with the secret argument set to a key of your choice:
php artisan down --secret="mysecretkey"

Note: Ensure that the mysecretkey argument is a complex key for security reasons.

After following the entire process, your website is accessible to you alone.

To access your website, your link should resemble the following:

http://example.com/mysecretkey

In the above link, mysecretkey should be replaced by the argument you entered while running the php artisan down --secret="mysecretkey" command.

Note: Remember this tutorial pertains to Laravel versions 6 and 7.

Free Resources