I've been searching for a way to check in PHP if the maintenance mode of my Drupal website is enabled, but I only found some solutions for Drupal 7, which doesn't seem to work on D8.

Have got any ideas?

Thank you.

1 Answer 1


The maintenance mode of the site is a boolean value stored in a state. You can access it like this:

$state = \Drupal::state()->get('system.maintenance_mode');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.