Dolibarr/dolibarr · critical

host= , port= , user= , databasename=

Error message

host=${host}, port=${port}, user=${user}, databasename=${name}, ${db->error}

What it means

Generic DB connection failure page: if getDoliDBInstance() returns an error outside the website context, master.inc.php calls dol_print_error() dumping host, port, user, databasename and the driver error, then exits. It is Dolibarr's way of surfacing that the configured database is unreachable or rejected the login.

Solutions

  1. Read the driver error appended to the message to identify the exact cause
  2. Verify DB server is running and reachable (telnet host port)
  3. Correct host/port/user/name/password in htdocs/conf/conf.php
  4. Confirm the DB user has rights on the database from the web server host

Example fix

// before (conf.php)
$dolibarr_main_db_port='3307';
// after
$dolibarr_main_db_port='3306';
Defensive patterns

Strategy: retry

Validate before calling

// validate conf.php DB settings before deploy
foreach (['db_host','db_port','db_user','db_name'] as $k) {
  if (empty($dolibarr_main_{$k})) die("missing $k in conf.php");
}

Try / catch

// catch DoliDB connect failure in custom bootstrap
$db = getDoliDBInstance($type,$host,$user,$pass,$name,$port);
if (!empty($db->error)) { log_db_outage($db->error); retry_or_fail_gracefully(); }

Prevention

When it happens

Trigger: Any non-website page load where $db->error is truthy after connecting with conf.php values: wrong host/port, refused connection, bad user/password, unknown database, or unsupported DB type.

Common situations: DB credentials changed (password rotation); database server not running; firewall blocking port 3306; conf.php copied from another environment; 'Access denied for user' or 'Unknown database' from MySQL.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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

Appendix: source

Thrown at htdocs/master.inc.php:260

			$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
 */
if (!defined('NOREQUIREUSER')) {
	$user = new User($db);
}

/*
 * Create the global $hookmanager object

View on GitHub (pinned to 598aa4bdad)