Dolibarr/dolibarr · critical

SorryWebsiteIsCurrentlyOffLine

Error message

SorryWebsiteIsCurrentlyOffLine

What it means

When the database connection fails ($db->error set) during bootstrap and the request targets a hosted website page (script path under DOL_DATA_ROOT/website), Dolibarr responds with HTTP 503 and prints the translated 'SorryWebsiteIsCurrentlyOffLine' message, then exits. It tells visitors and search engines the website is temporarily unavailable rather than exposing DB details.

Solutions

  1. Check database server status (systemctl status mysql/mariadb) and restart if down
  2. Verify conf.php DB settings: $dolibarr_main_db_host, $dolibarr_main_db_port, $dolibarr_main_db_user, $dolibarr_main_db_name, $dolibarr_main_db_pass
  3. Test credentials manually (mysql -h host -P port -u user -p dbname)
  4. Check DB error logs for max_connections or access-denied errors

Example fix

// before (conf.php)
$dolibarr_main_db_host='old-db-host';
// after
$dolibarr_main_db_host='localhost';
Defensive patterns

Strategy: fallback

Validate before calling

// before serving website pages, verify DB reachability
$test = @mysqli_connect($host, $user, $pass, $name, (int)$port);
if (!$test) { show_maintenance_page(); }

Try / catch

// monitor for 503 responses on /website/* routes and alert ops
if ($httpCode === 503 && strpos($url, '/website/') !== false) { trigger_db_alert(); }

Prevention

When it happens

Trigger: A request to a page under the website directory (USEDOLIBARREDITOR/USEDOLIBARRSERVER not defined, SCRIPT_FILENAME starting with DOL_DATA_ROOT.'/website') while getDoliDBInstance() fails — bad DB host/port/credentials in conf.php, DB server down, or DB name wrong.

Common situations: MySQL/MariaDB stopped or crashed; conf.php pointing at the wrong DB host after a migration; wrong DB password after rotation; the public website view of Dolibarr's website module rendered while the DB is unreachable.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


AI-assisted analysis of Dolibarr/dolibarr@598aa4bdad (2026-09-14). Data as JSON: /api/errors/7a0665296b733509. Report an issue: GitHub.

Appendix: source

Thrown at htdocs/master.inc.php:253

	$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
	/**
	 * @var DoliDB $db
	 */

	if ($db->error) {
		if (is_object($langs)) {
			$langs->setDefaultLang('auto');
		}
		// If we were into a website context
		if (!defined('USEDOLIBARREDITOR') && !defined('USEDOLIBARRSERVER') && !empty($_SERVER['SCRIPT_FILENAME']) && (strpos($_SERVER['SCRIPT_FILENAME'], DOL_DATA_ROOT.'/website') === 0)) {
			$sapi_type = php_sapi_name();
			if (substr($sapi_type, 0, 3) != 'cgi') {
				http_response_code(503); // To tel search engine this is a temporary error
			}
			print '<div class="center" style="text-align: center; margin: 100px;">';
			if (is_object($langs)) {
				$langs->load("website");
				print $langs->trans("SorryWebsiteIsCurrentlyOffLine");
			} else {
				print "SorryWebsiteIsCurrentlyOffLine";
			}
			print '</div>';
			exit(1);
		}
		dol_print_error($db, "host=".$conf->db->host.", port=".$conf->db->port.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error);
		exit(1);
	}
}

// Now database connection is known, so we can forget password
//unset($dolibarr_main_db_pass); 	// We comment this because this constant is used in some other pages
unset($conf->db->pass); // This is to avoid password to be shown in memory/swap dump


/*
 * Create object $user

View on GitHub (pinned to 598aa4bdad)