How to fix “Error establishing a database connection”

by Phil Persson | Jan 22, 2017


As you no doubt know, Persson Technologies is a web design company. As such, we are not your source for technical support for your website. This is because we do not have access to the web server, database server, disk drives, routers, and other hardware that allow your website to function. In most cases if your website is down your web hosting company is your best resource. ¬†However, we can tell you what actions to take if you encounter the “Error establishing a database connection” message.

This usually happens because the name of the database or the database password has changed in your hosting account and WordPress has not been updated to reflect this change. Therefore, when WordPress attempts to contact the database the connection fails and that is exactly what this error message is telling you.

The way to fix this to use an FTP application (such as WinSCP or FileZilla) to access the wp_config.php file in the root of your website server:

Location of config file
Move the file to your local machine and using your favorite text editor (Notepad++, Kate, or Gedit are good examples), change the database password here:
Location of database password
Then send the file back up to the website server, overlaying the previous copy.

Now refresh the screen in your web browser and your website should be fixed!