{"record":{"id":"27d2544c2295ed86","repo":"flarum/framework","slug":"the-forum-is-currently-in-maintenance-mode","errorCode":null,"errorMessage":"The forum is currently in maintenance mode.","messagePattern":"The forum is currently in maintenance mode\\.","errorType":"http","errorClass":"MaintenanceModeException","httpStatus":503,"severity":"info","filePath":"framework/core/src/Http/Middleware/CheckForMaintenanceMode.php","lineNumber":34,"sourceCode":"use Psr\\Http\\Message\\ServerRequestInterface;\nuse Psr\\Http\\Server\\MiddlewareInterface;\nuse Psr\\Http\\Server\\RequestHandlerInterface;\n\nreadonly class CheckForMaintenanceMode implements MiddlewareInterface\n{\n    public function __construct(\n        private MaintenanceMode $maintenance,\n        private array $exemptRoutes,\n    ) {\n    }\n\n    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface\n    {\n        $actor = RequestUtil::getActor($request);\n        $isRouteExcluded = in_array($request->getAttribute('routeName'), $this->exemptRoutes, true);\n\n        if (! $isRouteExcluded && $this->maintenance->inMaintenanceMode() && ! $actor->isAdmin()) {\n            throw new MaintenanceModeException('The forum is currently in maintenance mode.');\n        }\n\n        return $handler->handle($request);\n    }\n}\n","sourceCodeStart":16,"sourceCodeEnd":40,"githubUrl":"https://github.com/flarum/framework/blob/4b939f685389bfe8a380e9e28ddf305a1c66950c/framework/core/src/Http/Middleware/CheckForMaintenanceMode.php#L16-L40","documentation":"CheckForMaintenanceMode::process throws MaintenanceModeException('The forum is currently in maintenance mode.') when the forum is switched to maintenance and the requesting user is neither an admin nor hitting an exempt route. Flarum uses this to take the site offline for everyone except administrators.","triggerScenarios":"Any request while the 'maintenance_mode' / downtime setting is enabled, from a non-admin actor, whose routeName is not in the exempt-routes list configured for the middleware.","commonSituations":"Users browsing during a planned upgrade; monitoring tools hitting public endpoints during maintenance; API clients (mobile apps) failing during maintenance windows; admins wondering why a secondary account can't log in.","solutions":["Log in with an administrator account (admins bypass the check).","Wait for the maintenance window to end, or ask the admin to disable maintenance mode in the admin dashboard.","If specific endpoints (e.g. webhooks or health checks) must stay reachable, add their route names to the middleware's exempt routes configuration."],"exampleFix":"// before: hitting a protected route during maintenance\n// GET /api/discussions -> 503 MaintenanceModeException\n\n// after: register the route as exempt when enabling maintenance\nnew CheckForMaintenanceMode($maintenance, ['health', 'webhook']);","handlingStrategy":"try-catch","validationCode":"// before scheduled jobs hitting public endpoints, check status\nconst res = await fetch('/api/forum-status');\nconst inMaintenance = res.status === 503;","typeGuard":null,"tryCatchPattern":"try {\n  return await apiFetch('/api/discussions');\n} catch (e) {\n  if (isMaintenanceMode(e)) { scheduleRetry(e.retryAfter); return; }\n  throw e;\n}","preventionTips":["Check the admin dashboard / status endpoint before running user-facing automation.","Schedule maintenance during low-traffic windows and notify clients.","Add health-check route names to the exempt-routes list for monitors.","Handle 503 responses with backoff and retry in API clients."],"tags":["flarum","maintenance-mode","middleware","http","availability"],"backgroundTag":"service-unavailable","analyzedSha":"4b939f685389bfe8a380e9e28ddf305a1c66950c","analyzedAt":"2026-09-15T18:09:20.879Z","contentChangedAt":"2026-09-15T18:09:20.879Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}