Overview
The following helps you identify and fix some common database issues when you see the Error establishing a database connection message.
How to fix an 'Error establishing a database connection'
This error indicates that your website files on the webserver cannot connect to the database on the database server. The following sections outline common reasons for this error and how to resolve them.
Correcting database credentials in your config file
Every website connecting to a database has a configuration file that stores essential credentials for connecting:
- Database username
- Database username password
- Database hostname
- Database name
If the database login information changes in the panel without updating the site’s configuration file, your site will not connect to the database. Below are standard config files for popular software:
-
Software Config file name Config file location Concrete CMS database.php application/config/ Joomla configuration.php In the site's main directory MediaWiki Localsettings.php In the site's main directory phpBB config.php In the site's main directory WordPress wp-config.php In the site's main directory Zen Cart configure.php includes/
Finding your database credentials
See this article for instructions on how to locate your database credentials.
Never use localhost for your hostname. You must only use the hostname set up in your DreamHost panel.
Fixing an incorrect hostname
The hostname is the URL you use to access your database. See this article to learn more about how to locate this URL in your panel.
To test the hostname, try accessing it via a web browser. If nothing loads, you likely have an incorrect hostname. Hostnames on the same server are interchangeable; if another hostname works, you can use that one. If you don't have an alternative, create a new hostname and wait for it to propagate. For more information, view the phpMyAdmin article article.
If the hostname loads but prompts for a username and password, check that the username and password in your config file are correct. See this article for details on how to obtain the correct credentials in your panel.
It's possible your MySQL server is not responding due to networking issues. If you see an error when attempting to connect to phpMyAdmin, contact support for further assistance.