Error establishing a database connection

Overview

This article helps you identify and fix the common causes of the Error establishing a database connection message — the error your site shows when your website files on the webserver cannot connect to the database on the database server.

How do I 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.

How do I correct database credentials in my 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:

SoftwareConfig file nameConfig file location
Concrete CMSdatabase.phpapplication/config/
Joomlaconfiguration.phpIn the site's main directory
MediaWikiLocalsettings.phpIn the site's main directory
phpBBconfig.phpIn the site's main directory
WordPresswp-config.phpIn the site's main directory
Zen Cartconfigure.phpincludes/

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.

How do I fix 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.

Is the database server available?

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.

See also

Still not finding what you're looking for?