You might want to access your web app even though it’s in maintenance mode. It is possible to achieve this by writing custom middleware that checks for maintenance mode.

By default, Laravel ships with CheckForMaintenanceMode middleware. The handle() method, which gets triggered, looks like this:

public function handle($request, Closure $next)
{
    if ($this->app->isDownForMaintenance()) {
        throw new HttpException(503);
    }

    return $next($request);
}

You’d want to create a custom middleware and use that instead.

Run php artisan make:middleware CheckForMaintenanceMode and file app/Http/Middleware/CheckForMaintenance.php will get created.

Open it up and modify the handle() method to suit your needs, likewise:

public function handle($request, Closure $next)
{
    if ($this->app->isDownForMaintenance() &&
        !in_array($request->ip(), ['123.123.123.123', '124.124.124.124']))
    {
        return response('Be right back!', 503);
    }

    return $next($request);
}

This will essentially allow the requests from those IP addresses, regardless of whether the app is in maintenance mode or not.

All that’s left is to swap out Illuminate’s CheckForMaintenanceMode middleware for our custom one. Open app/Http/Kernel.php and replace line

Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class

with

App\Http\Middleware\CheckForMaintenanceMode::class

Hope this was helpful!