Joomla Database Connection Error (2): Could Not Connect to MySQL

Joomla 2.5 has reached its end of life as for 12/31/2014. Please be advised this may be a security risk to your website. You can view more information about the end of life here.

Joomla 2.5 utilizes a database to store a majority of a site’s content. For example, if you write a new article in Joomla, the article is written to the database. As the database is vital for Joomla to run, if Joomla cannot connect to your database and access information, you will see database related error messages on your site. In this article, we’ll show you a few common errors and how you can resolve them.

Common Joomla 2.5 Database Connection Error Messages:

Database connection error (2): Could not connect to MySQL.


This error message generally means that your Joomla’s configuration.php file has either the wrong database name or database username. In our testing environment, we changed both the database username and password, and in each separate occasion the same error message occurred.

You should review your configuration.php file and ensure you are using the correct MySQL username and password. These settings will appear in the file as:

public $user = 'userna5_dbuser';
public $password = 'dbpass';

If you are sure the settings are correct, it is recommend to reset your database user’s password and update your configuration.php file with the new password. This will help ensure that you have the correct database password set.

Database connection error (3): Could not connect to database

database connection error could not connnect to database

This error message usually means that you are connecting to the wrong database server. For most Joomla installations, the Joomla files themselves and the database it connects to are on the same server. When this is the case, “localhost” should be used the database server. We recreated this error message by setting the database host to “localhosttt” (localhost spelled wrong).

If your Joomla site is setup like most, check your configuration.php file and ensure your database host is set to “localhost”. This is setting looks like the following in your config file:

public $host = 'localhost';

MySQL server has gone away

mysql server has gone away

The “MySQL server has gone away” error generally means that there is a problem with MySQL on the server, therefor it is unavailable for use. In our testing environment, we shut down MySQL and received such a warning.

If you are not an InMotion Hosting customer, you should contact your current web hosting provider with the necessary details for more help with this. At InMotion Hosting, we monitor our servers 24 hours a day. If MySQL is not functioning on a server, we are aware usually seconds after the issue occurs. You can rest assured we are on top of the problem and that it should be corrected shortly. As always, you can contact our Support Team if you desire to report such a problem.

Most often, if Joomla has been working fine and suddenly stops working due to a database error, there is a problem with the database on your server. You’ll want to contact your hosting provider for further assistance. If you have recently made a change to Joomla and then you begin to see database errors, instead of contacting your host you should first check your database settings in your configuration.php file.

23 thoughts on “Joomla Database Connection Error (2): Could Not Connect to MySQL

  1. in the MYSQL console write this sql query to set the password to whatever you want:
    SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘MyNewPass’); then access phpmyadmin by the username root and newly assigned password. Click the privilege then find and mark no-password button and click Go.
    It will reset all your passwords and when you try your site it will work. This saved me.


  2. This webpage is not available

    my website is created in joomla inside the linux centos6.0

    I cant access the website in the internet 

    This webpage is not available



    but i can access it in the LAN networks …

    Can you help fix this error?

    1. Hello Aris,

      This is not a database connection issue, but a general connection issue. Is it only that device? Have you tried others on that network? Other browsers on that device? Other networks? Cleared caching for the browsers? Checked other sites on the same computer?

      Kindest Regards,
      Scott M

  3. I need help with this error pls:

    Got error 28 from storage engine SQL=SELECT, a.title, a.alias, a.title_alias, a.introtext, a.checked_out, a.checked_out_time, a.catid, a.created, a.created_by, a.created_by_alias, CASE WHEN a.modified = 0 THEN a.created ELSE a.modified END as modified, a.modified_by, as modified_by_name,CASE WHEN a.publish_up = 0 THEN a.created ELSE a.publish_up END as publish_up, a.publish_down, a.attribs, a.metadata, a.metakey, a.metadesc…

    1. Hello Yahaya,

      Sorry to hear that you’re getting an error with your database. The error you’re seeing is not related to a connection issue. It’s more related to the space you have available for your database. I researched the error and it is related to the space available to the database or temporary files. You may need to speak with your hosting provider technical support. If InMotion Hosting is your host, then you will need to submit a support ticket to live support. You may also want to check the size of your database and use the cPanel option to repair it to see if it will help.

      I hope this helps to answer your question, please let us know if you require any further assistance.

      Arnel C.

  4. This article is good. Hands on approach to resolving errors. It helped me solvemine and my site is now up and running.


    1. Hello Nansi,

      Sorry for the problem that you’re having. However, you have not provided any details to the issue, so we can’t help you without any further information. Please describe the problem, provide details on any error messages, and explain steps that you take to duplicate the error. If you can provide us a URL or other information on the website, it would also help us (if you are a customer).

      Kindest regards,
      Arnel C.

    1. Hello Constantin,

      I see your site has the same error as described in the article. Have you followed the instructions? If so, where are you stuck?

      Kindest Regards,
      Scott M

  5. Hey guys, thats for the page it’s been really usefule although  I’ve tried to follow the steps which are great but when I click on the link reviewing the php file and it asks me to go to the administrator page I get the same SQL error as I do on my homepage which means I can’t access the admin section to correct the configuration.php content. Any ideas?



    Thanks a lot,



  6. Database connection error (2): Could not connect to MySQL. my joomla website was working very fine but after i have inserted the module for cintact suddely it started to show me that it cant connect to the database…..izt a module or server it self

    1. Hello Maanda,

      Thank you for your question. This could be caused by an issue with your server’s services, or a misconfiguration of your database settings.

      I first recommend reading our detailed guide database connection errors.

      We would be happy to further assist you, but will need additional information such as the domain name of the site, and a link to the error message.

      If you have any further questions, feel free to post them below.

      Thank you,

  7. I’m very grateful because your site help-me. Thanks a lot. May Allah bless u with full grace

    1. Hello Carolina,

      I’m sorry to hear you’re having problems with connecting to your Joomla database. Unfortunately, you have given us no details with which to help you. Have you at least gone through the steps above and checked to see that the correct user name and password are being used for the database. One way to check is to use the database program that comes with your hosting. Since it doesn’t appear that you’re hosted with our service, we can’t really check from here. You can reference our article on connecting to a database with MySQL workbench for further information on testing (using a different program).

      I hope this helps give you at least a starting point. If you wish for us to investigate the issue further, we need further information on how you’re connecting to the database.

      Arnel C.

  8. Very useful and resourceful, helped me save so much time figuring out the cause of the error..Thanks so so much..

    Much appreciation:)

  9. Thanks. Why this error comes even when there is no change in MySQL db.  The fact is that if you open the site ,It is opeing at first and then when I am refreshing it 3-4 times that error is coming. Plz help. You  can check the error at my site at    Thanks in advance

    1. I was unable to produce any errors on your site so it appears to be just a previous intermittent issue that is now resolved.

Was this article helpful? Let us know!