Laravel 5 Maintenance Mode

Enabling and disabling maintenance mode in Laravel 5 is simple, you just need to issue following artisan commands –

  • To enable maintenance mode php artisan down.
  • To disable maintenance mode php artisan up.

That is it. If you want to allow the application to listed IPs, even when the application is in maintenance mode. We need to override the default middleware : \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php (default laravel5 uses).

Laravel 5 Maintenance Mode
First we need to get current user ip address by using laravel5 powerful request object method $this->request->getClientIp()

Than copy the default laravel5 maintenance middleware in \app\Http\Middleware\CheckForMaintenanceMode.php and make changes as shown below –

Now open \app\Http\Kernel.php file and comment out default middleware and add our custom middleware

Maintenance Mode Response Template – The default template for maintenance mode responses is located in resources/views/errors/503.blade.php.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.