How to Fix the Database Connection Error in Joomla

How to Fix the Database Connection Error in Joomla

Do you have a blank page on your Joomla site showing this message?

Error displaying the error page: Application Instantiation Error: Could not connect to MySQL.

This means that your Joomla system can't connect to your database. Since your site's data is stored there, it is highly important you fix the connection to get your site back.

Continue reading this post to find out how to fix the database connection error.

In my experience, there are two possible solutions. Depending on your situation, choose the one that suits better your needs.


Solution #1. If the error is intermittent

This happens if your MySQL server is up and down intermittently. You would see your site working fine for some periods of time but suddenly it would return the annoying error. This may happen in an endless cycle.

  • In that case, report the issue to your hosting provider. They should be able to figure out a solution.

Solution #2. Double check the database details

  • Open configuration.php file with a code editor.
  • Look for these variables:

public $host = 'your-database-host';
public $user = 'your-database-user-name';
public $password = 'your-database-user-password';
public $db = 'your-database';

  • Let's confirm the information is correct through your cPanel, by clicking on the "MySQL Databases" section:

joomla database connection error

  • Look for your database ($db value) on the list, see if the $user match with "Privileged users" next to the database name:

joomla database connection error

If you are unsure about the value for $password:

  • Scroll down until you reach the "Current users" section.
  • Click "Set password" for the database username.

joomla database connection error

  • Type the value from $password as a new password.
  • Click "Change password".

joomla database connection error

The value for $host is commonly 'localhost', unless the server provides a different one.

  • Refresh your site and hopefully, it will work this time.

What's Next?


What's Next?

Save $1,000's when you sign up for Joomlashack's Everything Club.

You will get your hands on our extensive range of over 20 extensions, plus legendary support!

Click here to join the Everything Club