how to use maintenance mode in laravel 9

In this section we will see how to use maintenance mode in laravel 9. We can maintenance mode command to set laravel app in maintenance mode.

Laravel 9 create custom 404 error page example


Laravel Maintenance Mode Command

To enable laravel project maintenance mode run down artisan command:

php artisan down

After running command your laravel app will be in maintenance mode like below image.

laravel 9 maintenance mode 503

laravel 9 maintenance mode 503



Laravel maintenance refresh Command

You can instruct your browser to automatically refresh the page after a specified number of seconds by setting the Refresh HTTP header when invoking the down command.

php artisan down --refresh=15

For 1 minutes

php artisan down --refresh=60


Laravel maintenance retry Command

You may also provide a retry option to the down command, which will be set as the Retry-After HTTP header's value, although browsers generally ignore this header:

php artisan down --retry=60

Read Also: Tailwind CSS Maintenance Page Example


Laravel Bypassing Maintenance Mode

To allow maintenance mode to be bypassed using a secret token, you may set up a maintenance mode bypass token with the secret option.

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

After placing the application in maintenance mode, you may navigate to the application URL matching this token and Laravel will issue a maintenance mode bypass cookie to your browser:

In local host project.

http://127.0.0.1:8000/1630542a-246b-4b66-afa1-dd72a4c43515

In live project.

https://example.com/1630542a-246b-4b66-afa1-dd72a4c43515 


Laravel 9 Disabling Maintenance Mode

To disable laravel maintenance mode use artisan up commad.

php artisan up