{"record":{"id":"a6a364c1480f35f6","repo":"Dolibarr/dolibarr","slug":"host-host-port-port-user-user-databasename-name-db-error","errorCode":null,"errorMessage":"host=${host}, port=${port}, user=${user}, databasename=${name}, ${db->error}","messagePattern":"host=(.+?), port=(.+?), user=(.+?), databasename=(.+?), (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"htdocs/master.inc.php","lineNumber":260,"sourceCode":"\t\t\t$langs->setDefaultLang('auto');\n\t\t}\n\t\t// If we were into a website context\n\t\tif (!defined('USEDOLIBARREDITOR') && !defined('USEDOLIBARRSERVER') && !empty($_SERVER['SCRIPT_FILENAME']) && (strpos($_SERVER['SCRIPT_FILENAME'], DOL_DATA_ROOT.'/website') === 0)) {\n\t\t\t$sapi_type = php_sapi_name();\n\t\t\tif (substr($sapi_type, 0, 3) != 'cgi') {\n\t\t\t\thttp_response_code(503); // To tel search engine this is a temporary error\n\t\t\t}\n\t\t\tprint '<div class=\"center\" style=\"text-align: center; margin: 100px;\">';\n\t\t\tif (is_object($langs)) {\n\t\t\t\t$langs->load(\"website\");\n\t\t\t\tprint $langs->trans(\"SorryWebsiteIsCurrentlyOffLine\");\n\t\t\t} else {\n\t\t\t\tprint \"SorryWebsiteIsCurrentlyOffLine\";\n\t\t\t}\n\t\t\tprint '</div>';\n\t\t\texit(1);\n\t\t}\n\t\tdol_print_error($db, \"host=\".$conf->db->host.\", port=\".$conf->db->port.\", user=\".$conf->db->user.\", databasename=\".$conf->db->name.\", \".$db->error);\n\t\texit(1);\n\t}\n}\n\n// Now database connection is known, so we can forget password\n//unset($dolibarr_main_db_pass); \t// We comment this because this constant is used in some other pages\nunset($conf->db->pass); // This is to avoid password to be shown in memory/swap dump\n\n\n/*\n * Create object $user\n */\nif (!defined('NOREQUIREUSER')) {\n\t$user = new User($db);\n}\n\n/*\n * Create the global $hookmanager object","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/Dolibarr/dolibarr/blob/598aa4bdada683d17ca04b1842548821ff0eb6c6/htdocs/master.inc.php#L242-L278","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the driver error appended to the message to identify the exact cause","Verify DB server is running and reachable (telnet host port)","Correct host/port/user/name/password in htdocs/conf/conf.php","Confirm the DB user has rights on the database from the web server host"],"exampleFix":"// before (conf.php)\n$dolibarr_main_db_port='3307';\n// after\n$dolibarr_main_db_port='3306';","handlingStrategy":"retry","validationCode":"// validate conf.php DB settings before deploy\nforeach (['db_host','db_port','db_user','db_name'] as $k) {\n  if (empty($dolibarr_main_{$k})) die(\"missing $k in conf.php\");\n}","typeGuard":null,"tryCatchPattern":"// catch DoliDB connect failure in custom bootstrap\n$db = getDoliDBInstance($type,$host,$user,$pass,$name,$port);\nif (!empty($db->error)) { log_db_outage($db->error); retry_or_fail_gracefully(); }","preventionTips":["Test DB connectivity after any credential rotation","Use persistent monitoring for the DB port from the web host","Keep conf.php environment-specific and never share between prod/staging","Verify 'skip-name-resolve'/grant host matches web server IP"],"tags":["database","connection","config"],"backgroundTag":"database-query-failed","analyzedSha":"598aa4bdada683d17ca04b1842548821ff0eb6c6","analyzedAt":"2026-09-14T11:12:15.309Z","contentChangedAt":"2026-09-14T11:12:15.309Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}