Dolibarr/dolibarr · warning
Sorry, your application is offline.
Error message
Sorry, your application is offline.
What it means
When MAIN_ONLY_LOGIN_ALLOWED is set, Dolibarr restricts access to only the listed logins (maintenance mode). This branch fires when there is no logged-in session at all (or the login check otherwise left $ok=0): the visitor is told the app is offline and that only the listed administrators may connect for the moment.
Solutions
- Remove or empty MAIN_ONLY_LOGIN_ALLOWED in Home > Setup > Other Setup (or conf.php) once maintenance is over
- Log in as one of the allowed admin logins listed in the message
- Wait/retry later if maintenance is intentional
Defensive patterns
Strategy: fallback
Validate before calling
// check before deploy: SELECT value FROM llx_const WHERE name='MAIN_ONLY_LOGIN_ALLOWED';
Prevention
- Remove MAIN_ONLY_LOGIN_ALLOWED once maintenance ends
- Announce maintenance windows and verify the flag afterwards
- Automate a post-upgrade check that clears the restriction
When it happens
Trigger: MAIN_ONLY_LOGIN_ALLOWED global (e.g. 'admin') set in setup or conf.php; an anonymous visitor hits any page requiring main.inc.php, so session has no dol_login and $ok stays 0.
Common situations: Admin enabled maintenance mode after an upgrade and left it on; a user hit the site during a migration window; staging copies of production conf with the restriction still enabled.
Related errors
- You are logged with user
- Sorry, your application is offline. Only administrator users
- Access refused by IP protection. Your detected IP is
- Bad link. File is from another module part.
- If define NOREQUIREDB or NOREQUIRETRAN are set, you must…
AI-assisted analysis of Dolibarr/dolibarr@598aa4bdad (2026-09-14).
Data as JSON: /api/errors/a7ee5ef0c4fe1849.
Report an issue: GitHub.
Appendix: source
Thrown at htdocs/main.inc.php:192
// include DOL_DOCUMENT_ROOT.'/core/lib/phpsessionindb.inc.php
// If software has been locked. Only login getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED') is allowed.
if (getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')) {
$ok = 0;
if ((!session_id() || !isset($_SESSION["dol_login"])) && !isset($_POST["username"]) && !empty($_SERVER["GATEWAY_INTERFACE"])) {
$ok = 1; // We let working pages if not logged and inside a web browser (login form, to allow login by admin)
} elseif (isset($_POST["username"]) && in_array($_POST["username"], explode(';', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')))) {
$ok = 1; // We let working pages that is a login submission (login submit, to allow login by admin)
} elseif (defined('NOREQUIREDB')) {
$ok = 1; // We let working pages that don't need database access (xxx.css.php)
} elseif (defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) {
$ok = 1; // We let working pages that ask to work even if only login enabled (logout.php)
} elseif (session_id() && isset($_SESSION["dol_login"]) && in_array($_SESSION["dol_login"], explode(';', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')))) {
$ok = 1; // We let working if user is allowed admin
}
if (!$ok) {
if (session_id() && isset($_SESSION["dol_login"]) && !in_array($_SESSION["dol_login"], explode(';', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')))) {
print 'Sorry, your application is offline.'."\n";
print 'You are logged with user "'.$_SESSION["dol_login"].'" and only administrator users (' . str_replace(';', ', ', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')).') is allowed to connect for the moment.'."\n";
$nexturl = dolBuildUrl(DOL_URL_ROOT . '/user/logout.php', [], true);
print 'Please try later or <a href="'.$nexturl.'">click here to disconnect and change login user</a>...'."\n";
} else {
print 'Sorry, your application is offline. Only administrator users (' . str_replace(';', ', ', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')).') is allowed to connect for the moment.'."\n";
$nexturl = dolBuildUrl(DOL_URL_ROOT . '/');
print 'Please try later or <a href="'.$nexturl.'">click here to change login user</a>...'."\n";
}
exit;
}
}
// Activate end of page function
register_shutdown_function('dol_shutdown');
// Load debugbar
if (isModEnabled('debugbar') && !GETPOST('dol_use_jmobile') && empty($_SESSION['dol_use_jmobile'])) {View on GitHub (pinned to 598aa4bdad)